subprocess confusion

Tim Arnold tiarno at sas.com
Mon Apr 16 13:36:00 EDT 2007


Hi,
Just discovered that my subprocess call with the preexec_fn wasn't doing 
what I thought.
If 'machine' value is different than the current machine name, I want to 
remsh the command to that machine, but obviously I misunderstood the 
preexec_fn arg.

Should I just put the remsh in the actual command instead of preexec_fn?
thanks,
--Tim Arnold
-------------------------------
if machine == socket.gethostname():
    shname = None
else:
    shname = lambda :'/bin/remsh %s ' % (machine)
p = subprocess.Popen(preexec_fn = shname,
        shell  = True,
        args   = command,
        stderr = subprocess.STDOUT,
        stdout = log,
        env    = env,
        )
try:
    p.wait()
    if log:
        log.close()
except:
    pass

------------------------------- 





More information about the Python-list mailing list