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?
-
1Probably I don't understand at all your question, but, it looks like it is a shell scripting question, instead a python question.juanefren– juanefren2010年08月30日 19:26:36 +00:00Commented Aug 30, 2010 at 19:26
-
You're going to have to help us by being more specific.Dennis Williamson– Dennis Williamson2010年08月30日 20:24:19 +00:00Commented Aug 30, 2010 at 20:24
-
I don't mind if I don't get the "Best Answer" checkmark, but could you please give it to someone so this stops cluttering up the list of unanswered questions?ssokolow– ssokolow2010年09月27日 15:25:33 +00:00Commented Sep 27, 2010 at 15:25
3 Answers 3
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.
3 Comments
--runtest but not know how? Are you having trouble getting the script to run at all from an initscript? Is there some other problem I didn't guess?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.
Comments
Here you'll find all you need in terms of how to pass an argument to a shell script.