开发者

run python command line arguments in shell script

开发者 https://www.devze.com 2023-01-13 14:04 出处:网络
I have a script which takes in few arguments ./hal --runtest=example whe开发者_开发问答re example = /home/user/example.py

I have a script which takes in few arguments

./hal --runtest=example

whe开发者_开发问答re example = /home/user/example.py

how can I pass these arguments in shell script?


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.


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.


Here you'll find all you need in terms of how to pass an argument to a shell script.

0

精彩评论

暂无评论...
验证码 换一张
取 消