August 7th, 2013, 02:49 AM
Calling shell script from python
I am trying to run shell script with xterm in python using subprocess.
I not getting proper syntax for this.
I have tried this piece of code but its not working.
Here fname2 is argu to my script.
subprocess.call(["xterm -e","./script.sh", fname2])
August 7th, 2013, 03:04 AM
Got the solution
subprocess.call(["xterm" ,"-e","./script.sh", fname2])
August 7th, 2013, 03:12 AM
Each string must be its own element. This includes switches. Also, xterm has a habit of self-destructing instantly, so you might want to add "hold" to your argument list:
fname2 = 'a string you got somewhere else'
exec_args = ['xterm', '-e', './some_script.sh', fname2, 'hold']