How to run bash script with getopt included in python?

Question:

I am running a script in the ubuntu terminal and it works fine.

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

I want to run the same script in python os or subprocess but I am getting an error :

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

On line 36 I have :

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

How can I run this script as I run in the terminal using python?

Asked By: Nagmat

||

Answers:

getopt is not in your PATH and then not found.

Try:

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

assuming /usr/bin/ is where getopt is located.

Answered By: Diego Torres Milano
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.