Call Python script from bash with argument

2019-01-10 08:00发布

I know that I can run a python script from my bash script using the following:

python python_script.py

But what about if I wanted to pass a variable / argument to my python script from my bash script. How can I do that?

Basically bash will work out a filename and then python will upload it, but I need to send the filename from bash to python when I call it.

7条回答
家丑人穷心不美
2楼-- · 2019-01-10 08:48

use in the script:

echo $(python python_script.py arg1 arg2) > /dev/null

or

python python_script.py "string arg"  > /dev/null

The script will be executed without output.

查看更多
登录 后发表回答