Fun!

testo = [line for line in commands.getoutput('ls -la').split('\n')]
for line in testo:
   print line

spits out nicely formatted ls data.

It's Shelly!



Ertl, John wrote:

Hugo,

That looks like it will work great.

Thanks,

John

-----Original Message-----
From: Hugo Gonz�lez Monteverde [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 22, 2004 12:41
To: [EMAIL PROTECTED]
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...)

Hugo


Ertl, John wrote:


Roger,

I have been doing it the Pythonic way (that is why I have no idea about


how


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


in


20 years) it could be set to something else.



_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor






_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Reply via email to