Passing arguments to a shell script
This problem is particular to the shell 'sh' in Solaris.
My requirement is to execute a shell script in the current shell.
I execute as ' . ./temp.sh 1 2 3 '
and temp.sh is as simple as :-
echo $1 $2 $3
However $1 $2 and $3 do not get recognised.
I can invoke the script as 'sh temp.sh 1 2 3'
or '. ./temp.sh 1 2 3' in bash. These qork ok.
My requirement is to ultimately set some env vars in the script so I need the script to run in the current shell.
If you are 'dotting' the file then as you are not invoking it, as such, just including
it in the current script, so the $1 $2 $3 will be the same as the current shell.
So any vars visible in the 'calling' script will be visible in the dotted script anyway.
If you want to reset $1 $2 $3 you can use set, eg:
Thanks, it worked
a pleasure ;)
|All times are GMT -5. The time now is 11:51 PM.|