[Tutor] Popen? or something else

Ertl, John john.ertl at fnmoc.navy.mil
Wed Dec 22 21:43:13 CET 2004


That looks like it will work great.  



-----Original Message-----
From: Hugo González Monteverde [mailto:hugonz-lists at h-lab.net]
Sent: Wednesday, December 22, 2004 12:41
To: tutor at python.org
Cc: Ertl, John
Subject: Re: [Tutor] Popen? or something else

You may use the 'commands' module, if your subprocess should return
right away, then you can use:

import commands

mystring = commands.getoutput("dtg")


then mystring should have "2004122212" (and possibly '\n', but you'll
have to check that out, not sure about your command)in it...

Hope it helps, it sure is quicker than popen (I only use popen if I need
to keep  reading the output, for a one-time capture, I personally prefer
the "commands" module...)


Ertl, John wrote:
> Roger,
> I have been doing it the Pythonic way (that is why I have no idea about
> Popen works) but I need to make sure (the systems guys called me on it)  I
> use the same dtg as everyone else...it is possible (has not happened yet
> 20 years) it could be set to something else.

More information about the Tutor mailing list