parsing a file [newbie]
Nils Hensel
nils at hhk.de
Wed Jan 17 04:03:17 EST 2001
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
> __________________________________________________________________
>
>
More information about the Python-list
mailing list