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
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.
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.....
good link wit some info on arguments ~> http://www.linuxcommand.org/wss0130.php
|All times are GMT -5. The time now is 09:40 PM.|