tags:

views:

64

answers:

2

I have a script which takes in few arguments

./hal --runtest=example

where example = /home/user/example.py

how can I pass these arguments in shell script?

A: 

I'm having trouble figuring out what you're asking, but assuming your question is "How can a shell script pass dynamic arguments to a command that happens to be written in Python" and you are using a Bourne-family shell (very likely), the simplest correct answer would be

example=/home/user/example.py
./hal "--runtest=$example"

The shell will resolve the quoting and the script will see --runtest=/home/user/example.py without breaking if you later decide to pass in a path containing spaces.

ssokolow
Here are more details:I have an automation framework written in python. It is executed from command line as ./hal --runtest=<testcase>Now I created a .sh script under /etc/init.d which runs automatically after system reboot. This script when executed should execute /hal --runtest=<testcase> without any user intervention. I need a way to pass the arguments or execute the python script in the .sh script.Please let me know if you need more details
newbie
ssokolow
I got it worked. Thanks all for your answers
newbie
In that case, you'll want to make sure you don't forget to mark an answer as the best answer and hand out "This answer is useful" (up arrow) clicks appropriately. As a new user, half my motivation is earning points. (The other half if me being obsessively nice) As you may have noticed, until we get 50 points, we can't even comment unless we're the questioner or the answerer.
ssokolow
A: 

Take a look a the following:

http://lowfatlinux.com/linux-script-variables.html

It is Bash specific though and as per comments above not sure which shell you're using.

Jon