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

roejwanj  于 2022-11-16  发布在  Shell
关注(0)|答案(1)|浏览(121)

我在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在终端中运行时运行此脚本?

yb3bgrhw

yb3bgrhw1#

getopt不在您的PATH中,因此找不到。
请尝试:

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

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

相关问题