简体   繁体   中英

Using a bash script to execute python script with arguments

I have been searching for an answer to no avail. I have a python script that I would like to run that has quite a few arguments. It works just fine when I run the command from the terminal, but as soon as I try to put it in a bash script it no longer works.

script.py --arg1 --arg2 --arg3 --arg4 --arg5

This works.

#!/bin/bash
script.py --arg1 --arg2 --arg3 --arg4 --arg5

This does not. I get no error message or output.

Try this

#!/bin/bash
python script.py --arg1 --arg2 --arg3 --arg4 --arg5

The above assumes python executable is present in your path. If it is not you could also use the full path to python as follows

#!/bin/bash
/usr/bin/python script.py --arg1 --arg2 --arg3 --arg4 --arg5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM