LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2006, 05:08 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
bash, passing arguments


I have added to /bin a bash script which just opens a program. I don't know if this is a good way to do it, but I don't know where to put an alias for all users.

I just would like one of two questions to be answered based on this case: if alias is better then just makeing a bash script that runs the program answer question 1 else 2

1. Where should I put the alias so all users can just type the name of the program instead of the whole path to it

2. How may I "redirect" all arguments to the program executed in bash script

Thank you!
 
Old 02-05-2006, 05:34 PM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
1) You don't need an alias - just put it in /usr/bin with permissions 755.
2) The arguments are in variables $1 $2 $3 etc., with those being the first, second, and third argument respectively.
 
Old 02-05-2006, 09:04 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Four
I have added to /bin a bash script which just opens a program. I don't know if this is a good way to do it, but I don't know where to put an alias for all users.

I just would like one of two questions to be answered based on this case: if alias is better then just makeing a bash script that runs the program answer question 1 else 2

1. Where should I put the alias so all users can just type the name of the program instead of the whole path to it

2. How may I "redirect" all arguments to the program executed in bash script

Thank you!
You don't need a script just to open a program.

Whenever you have an executable file you can put the pathname in the PATH system variable---or you can link to a directory that is already in PATH. ("echo $PATH" to see whats there)

Passing variables to the program must be written into the script. Here is a crude example:
script name is myscript
program which it will run it myprogram

call the script with "myscript (123)"
inside the script, call the program with "myprogram ($1)"
Now you have passed the value 123 thru the script and into myprogram.
Check a book or online guide for exact syntax.....
 
Old 02-06-2006, 08:24 AM   #4
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
good link wit some info on arguments ~> http://www.linuxcommand.org/wss0130.php
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH Script: variable values referencing for console arguments sadarax Programming 1 11-14-2005 05:23 PM
logname: no login name, -bash: [: too many arguments da_kidd_er Linux - General 1 10-27-2004 02:09 PM
[bash-scripting]functions + arguments hylke Programming 14 10-05-2004 01:48 AM
bash arguments stuckinhell Programming 6 08-13-2004 05:10 AM
bash scripting - referring to external arguments into loops linsson Linux - General 2 07-23-2004 12:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration