Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass parameters from .bat to .sh

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
US
How would I pass some parameters from inside .bat file to a .sh file.

If I do
test.sh %1 %2
from inside my .bat file, I dont know how to retrieve the parameters from within the .sh

Thanks
 
The parameters are $1, $2, etc.
So, in your example, whatever %1 is will be $1 in test.sh
But, how are you running DOS .bat files and *nix .sh files in the same environment? That doesn't make sense.

Ceci n'est pas une signature
Columb Healy
 
Ok, that explains it

You might also want to look at $# (the number of arguments) and $@ and $* which are all the arguments. i.e. If the call is
Code:
myscript one two three
and the script is
Code:
echo $1
echo $2
echo $3
echo $#
echo $*
Then the output should be
Code:
one
two
three
3
one two three

Notice that in shell scripts variables are denoted by the $ sign. So, what in a batch script would be %COUNT%, in a shell script it is $COUNT. If you need to delimit it try ${COUNT}


Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top