[英]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.
我有一个我想运行的 python 脚本,它有很多参数。 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.
当我从终端运行命令时,它工作得很好,但是一旦我尝试将它放入 bash 脚本中,它就不再起作用。
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.以上假设您的路径中存在 python 可执行文件。 If it is not you could also use the full path to python as follows
如果不是,您也可以使用 python 的完整路径,如下所示
#!/bin/bash
/usr/bin/python script.py --arg1 --arg2 --arg3 --arg4 --arg5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.