|
|
How to make shell script that does this?
|
|
|
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
I'm having trouble making a SH shell script. I'm trying to have it accept 2 arguments, and then execute a command line app, passing the 2 arguments into the arguments of the command line app it's calling, along with some other arguments that are static. In addition, the execute it calls is not a hard coded path, but rather in the same directory the SH shell script is running in.
Any pointers? Thanks!
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Easy... $0 = the original command, $1 = argument one, $2 = argument two, etc.
So, for example:
sh myscript.sh --source /path1 --dest /path2
$1 = --source
$2 = /path1
$3 = --dest
$4 = /path2
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I'm not sure how much "pointer" you're looking for, so here's the general form of what you want to do:
Code:
if [ $# -ne 2 ]; then
echo "I TAKE TWO ARGUMENTS, GENIUS!"
else
./somecommand $@ -staticarg -anotherstaticarg
fi
(
Last edited by Chuckit; Dec 21, 2008 at 01:59 AM.
)
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
Thanks guys! I'll give it a shot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|