En Thu, 25 Sep 2008 12:36:00 -0300, EEK <[EMAIL PROTECTED]> escribió:
My goal is to start and stop separate Linux processes from a python program by specific PID. The output of these processes needs to have their stderr and stdout piped to a particular file, respectively. I've been able to make this work with subprocess.Popen only if the shell variable is set to False but I cannot pipe the outputs of the targets. When using subprocess.Popen with shell=True, I believe the returned PID is of the shell that opens the target process, not the target process itself. Therfore, I cannot stop the target process for the returned PID is not of that process.
Exactly.
prgm = program I want to run (compiled C) logfile = file I want to pipe output to What I need to do based on a simple shell call: program >& logfile (yes, that's it)
Use the stdout and stderr arguments. Something like this (untested): f = open(logfile, "w") proc = subprocess.Popen(["program","with","arguments"], stdout=f, stderr=f) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list