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

Reply via email to