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.

Is the example you gave using the new 2.4 Popen?  It looks like the older
popen.  I can get the older popen to work but not Popen.  

Thanks again.

John Ertl 

-----Original Message-----
From: Roger Merchberger [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 22, 2004 10:25
To: [EMAIL PROTECTED]
Subject: Re: [Tutor] Popen? or something else

Rumor has it that Ertl, John may have mentioned these words:
>All,
>
>I hate to ask this but I have just installed 2.4 and I need to get some
info
>from a subprocess (I think that is correct term).
>
>At the Linux command line if I input dtg I get back a string representing a
>date time group.  How do I do this in Python?  I would think Popen but I
>just don't see it.

It could, but there's also a better (IMHO), 'pythonic' way, something like
this:

def gettoday():

  import time
  today = time.strftime('%Y%m%d%H',time.localtime(time.time()))
  return (today)

>$ dtg
>2004122212

If you wanted to use popen, it would look rather like this:

import os
dtg_s = os.popen("/path/to/dtg").readlines()[0]

But this may use more system resources (spawning child shells & whatnot)
than doing everything internally with the time module in Python.

HTH,
Roger "Merch" Merchberger

--
Roger "Merch" Merchberger   | A new truth in advertising slogan
SysAdmin, Iceberg Computers | for MicroSoft: "We're not the oxy...
[EMAIL PROTECTED]          |                         ...in oxymoron!"

_______________________________________________
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