I have successfully used subprocess.Popen in the past when I wrapped binary files with a python script to format arguments / settings, etc.
The development of the nth wrapper, I did as usual ... but nothing happens.
Here is a little code:
print command p = subprocess.Popen(command, shell = True) result = p.communicate()[0] print vars(p) return result
And here is the conclusion:
/usr/bin/sh /tmp/run/launch.sh {'_child_created': True, 'returncode': 0, 'stdout': None, 'stdin': None, 'pid': 21650, 'stderr': None, 'universal_newlines': False}
As you can see, the goal is to create a shell script, configure everything that I need, and then execute it. I would prefer to use real python code, but unfortunately launch.sh calls third-party shell scripts that I don't want to try to replicate (although I have already insisted on python api for over a year now).
The problem is that:
- the shell script is not executed (it should start the process and display some little things)
- python exception not thrown
- nothing is displayed in the
p object, indicating an error
I tried check_call without any success ...
I am at a loss as to what I should do, and would be very happy if someone could point out my mistake or direct me to resolve ...
EDIT:
- Trying to run this on Linux (sh)
- a shell is needed to substitute variables in scripts called
EDIT 2:
Following the suggestion of badp , I changed the code and added
subprocess.Popen('ps', shell = True).communicate()
Right after the line p = ... that creates the process, here is the output:
/usr/bin/sh /tmp/run/launch.sh PID TTY TIME CMD 29978 pts/0 00:00:01 zsh 1178 pts/0 00:00:01 python 1180 pts/0 00:00:00 sh <defunct> 1181 pts/0 00:00:00 ps None
Apparently, the process is starting (although <defunct> ), and it should also be noted that I have a slight problem with passing parameters to ...
Thanks.