Rogelio wrote: > If I want to write this command to a file, would this be the right format? > > ********************************* > import subprocess > > (all my variables defined okay) > > perl_script=subprocess.call(['perl',perl_prog,ipfile,cmd,user,timeout,]) > > log=open('/tmp/pythonOutput.txt',w) > log.write(subprocess.call(perl_script)) > ********************************* > > The program runs (and outputs stuff on the screen okay), but when I > "cat /tmp/pythonOutput.txt", nothing is there.
The documentation is fairly clear: """ subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False) Run the command described by args. Wait for command to complete, then return the returncode attribute. """ > (While I'm not waiting for the entire program to run across all the IP > addresses, I would think that something would be go out into that log > file.) No, you'll get an integer return code and ultimately a TypeError when you pass that to the file's write() method. Read the docs on Popen.communicate() http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor