[Tutor] subprocess help, nohup

John washakie at gmail.com
Tue Nov 13 22:40:37 CET 2007


I've written a script which conducts several subprocess calls and then
ultimately calls a shell script which runs even more programs... my script
is using subprocess to execute a few sed calls, and then execute the script.
I'm getting strange behavior:

Here's a snippet of my script (any general comments are also welcome):

   if RUNS[k][3]==1: #model run complete, run is a DICT
    compWebPages=self.getCompletedWeb() #returns a DICT, which
RUNS[k][0] COULD be a key
    if RUNS[k][0] not in compWebPages.keys():
     cmd = """sed -e 's/RUNmin=[0-9][0-9]*/RUNmin=%s/g' %s  > jnk""" %
     cmd = """cat jnk | sed -e 's/RUNmax=[0-9][0-9]*/RUNmax=%s/g' > %s""" %
     subprocess.call(cmd,shell=True); subprocess.call('rm jnk',shell=True);
     cmd="""./%s""" % (runFile)
     print "Starting %s" % (runFile)
     print "Done with: %s" % (RUNS[k][0])
     cmd="""rm %s""" % (runFile); subprocess.call(cmd,shell=True)

You'll notice, the last subprocess call is commented out. Right now I'm just
getting to that point to make sure everything is working. So, it seems to
work, but I'm not sure how to get it to work if I change the command to
nohup. I still want python to wait for it to return, in fact, I would like
to set the python job running in the background as well... so what I'm
looking at doing is:

% nohup myControl.py
   ---> which will make several subprocess.call(s) including some that
should be 'nohupped' as well...

Suggestions on the syntax of how to do this?


Plone 2.5.3-final,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Five 1.4.1,
Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat
PIL 1.1.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071113/73531047/attachment-0001.htm 

More information about the Tutor mailing list