regarding popen function

Peter Hansen peter at engcorp.com
Sat Jun 18 12:38:47 EDT 2005


praba kar wrote:
>    The following way of popen function usage is
> wrong or not kindly give me answer regarding this
> 
> time = os.popen("echo %s | tai64nlocal" %
> line[2]).read()

Did you try it?  Just open the Python interactive interpreter and see 
what happens:

Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
 >>> import os
 >>> line = ['', '', '@4000000042b40a8716ebce34']
 >>> time = os.popen('echo %s | tai64nlocal' % line[2]).read()
 >>> time
'2005-06-18 07:50:21.384552500\n'

Or were you just asking if it was an appropriate way of using 
os.popen()?  If that's what you were asking, it would have been much 
clearer not to include the command itself, since clearly it just 
confuses people about what you are asking.

Yes, it's an appropriate way to use popen(), and it does seem to work if 
you have tai64nlocal in your path.

(Michael, tai64nlocal is a program that converts a special "packed" 
timestamp to human-readable form.  These timestamps are created, as I 
recall, by the multilog program that the developer of Qmail created.)

-Peter



More information about the Python-list mailing list