2009/4/4 dave selby <[email protected]>:
> os.popen3('nohup %s/core/kmotion_hkd2.py &> /dev/null &' % kmotion_dir)
>
> becomes ..
>
> subprocess.Popen('nohup %s/core/kmotion_hkd2.py &> /dev/null &' %
> kmotion_dir, shell=True)
>
> all is well except I now get
>
> nohup: appending output to `nohup.out'
>
> on the terminal which '&> /dev/null' used to ditch to /dev/null. I
> think this is because subprocess simulates the
> shell differently. Any idea how to ditch to /dev/null in subprocess ?
Subprocess by default does not store stdout and stderror. Try this:
proc = subprocess.Popen('nohup %s/core/kmotion_hkd2.py' % kmotion_dir,
shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
Now proc.communicate returns a tuple with (stdout, strderr). You can
also make stdout/stderr go to a file, below untested!
outfile = open('/tmp/myoutfile')
errfile = open('/tmp/myerrfile')
proc = subprocess.Popen('nohup %s/core/kmotion_hkd2.py' % kmotion_dir,
shell=True, stdout=outfile,stderr=errfile)
proc.communicate()
Greets
Sander
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor