regarding popen function

P

praba kar

Dear All,

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()

Actually here I didn't use any file handler and
I didn't close file handler.

regards
Prabahar







__________________________________________________________
Free antispam, antivirus and 1GB to save all your messages
Only in Yahoo! Mail: http://in.mail.yahoo.com
 
M

Michael Hoffman

praba said:
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()

I don't know, I don't know what tai64nlocal is or what's in line[2].
What happened when you tried it?

Personally I try to use the subprocess module rather than os.popen.
 
P

Peter Hansen

praba said:
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
 
M

Michael Hoffman

Peter said:
Michael, tai64nlocal is a program that converts a special "packed"
timestamp to human-readable form.

Thanks Peter. I was asking somewhat rhetorically but I have a love of
UNIX arcana and now I know. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,785
Latest member
undedgini

Latest Threads

Top