Reputation: 1607
I am trying to execute the following via a python script. But I am getting an error. Unknown option:-a test -b 25 -c 18 --d 25 23
script_args = '-a test -b 25 -c 18 --d 25 23'
subprocess.Popen(['/home/pi/bash/bash_script.sh', script_args])
I can copy the unknown option line and execute my script and the script runs without any errors and I am getting desired output.
/home/pi/bash/bash_script.sh -a test -b 25 -c 18 --d 25 23
What am I doing incorrectly via the python script?
Upvotes: 0
Views: 786
Reputation: 798526
You're passing a single argument composed of all those characters.
script_args = ['-a', 'test', ..., '23']
subprocess.Popen(['/home/pi/bash/bash_script.sh'] + script_args)
Upvotes: 3