LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash, passing arguments (http://www.linuxquestions.org/questions/linux-newbie-8/bash-passing-arguments-412001/)

Four 02-05-2006 06:08 PM

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!

scuzzman 02-05-2006 06:34 PM

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.

pixellany 02-05-2006 10:04 PM

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.....

muha 02-06-2006 09:24 AM

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


All times are GMT -5. The time now is 04:11 PM.