parsing a file [newbie]

Langa Kentane LangaK at discoveryhealth.co.za
Wed Jan 17 04:29:02 EST 2001


ONe thing I don't understand.
When I run os.popen('df -h'), this returns a pointer to an already open file
if I am not mistaken.

Now, to apply what you gave me to this scenario, how would I go about it.  I
am confusing myself silly here.

Please help.

-----Original Message-----
From: Nils Hensel [mailto:nils at hhk.de]
Sent: 17 January 2001 11:03
To: python-list at python.org
Subject: Re: parsing a file [newbie]


import os
my_command = "/whatever/you/like"
open ("output", "w").write (os.popen (my_command).read())
y = open ("output").read().split() [2]

Hope this works, I haven't tried it. This is quick and dirty though, better
implement some error checking.

Nils


"Langa Kentane" <LangaK at discoveryhealth.co.za> schrieb im Newsbeitrag
news:mailman.979720698.24494.python-list at python.org...
> How do I read a file.
> This is what I want to do.
> Run a command using os.popen and store the file info that it returns to x
> Open file x and read the contents.[ contents of x will be a mount output.]
> Go to the third column of the mount output and and store in y
>
> How would I go about doing this.
>
> __________________________________________________________
> Langa Kentane | TEL: (011) 290 3218
> Security Administrator | Cell: 082 606 1515
> DISCOVERY HEALTH | http://www.discoveryhealth.co.za
> __________________________________________________________________
>
>


-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list