繁体   English   中英

如何使用 python 中包含的 getopt 运行 bash 脚本?

[英]How to run bash script with getopt included in python?

我在 ubuntu 终端中运行一个脚本,它工作正常。

./run_script2.sh -b ./exercises/13_caching.py 

我想在 python 操作系统或子进程中运行相同的脚本,但出现错误:

./run_script2.sh: line 36: getopt: command not found

在第 36 行,我有:

opts=`getopt -o f:b:ia:p:d:h --long no-status-srv --long status-port: -- "$@"`

当我使用 python 在终端中运行时,如何运行此脚本?

getopt不在您的PATH中,然后找不到。

尝试:

opts=$(/usr/bin/getopt -o f:b:ia:p:d:h --long no-status-srv --long status-port: -- "$@")

假设/usr/bin/getopt所在的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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