I'm calling a C/C++ program from python with Popen
, python code should observe behavior of child process and collect some data for his own work.
Problem is that C code already uses pipes for calling some shell commands - so after my execution from python, C program cannot execute bash shell command.
Is there any way in calling from Popen
to specify that, child process should execute his own pipe command in shell???
I tried with shell=True, but doesn't help!
From your description, it seems that you are using Popen to execute a command line, which has Popen call a shell.
You should instead have Popen call your program directly, like this:
from subprocess import Popen,PIPE
p = Popen(['/my/fancy/program','-myarg1','-myarg2'],stdout=PIPE)
from_process = p.communicate()[1]
The best way is probably to use a TCP connection to localhost. If you are using a *nix, you can probably do it by opening a temporary file and polling it from the host application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.