running os commands [newbie]

Gilles Lenfant glenfant at equod.com.nospam
Fri Jan 12 06:12:55 EST 2001


Have a look at popen(...) in the "os" package.

Should fit your needs.

popen (command[, mode[, bufsize]])

Open a pipe to or from command. The return value is an open file object
connected to the pipe, which can be read or written depending on whether
mode is 'r' (default) or 'w'. The bufsize argument has the same meaning as
the corresponding argument to the built-in open() function. The exit status
of the command (encoded in the format specified for wait()) is available as
the return value of the close() method of the file object, except that when
the exit status is zero (termination without errors), None is returned.
Availability: Unix, Windows.
Changed in version 2.0: This function worked unreliably under Windows in
earlier versions of Python. This was due to the use of the _popen() function
from the libraries provided with Windows. Newer versions of Python do not
use the broken implementation from the Windows libraries.



"Langa Kentane" <LangaK at discoveryhealth.co.za> a écrit dans le message news:
mailman.979287198.15620.python-list at python.org...
> Greetings.
>
> I want to create a list call dfout[]
> In the list, I want to put the output of the df command.
> How do I go about doing this?  I have been trying to find this in the
docs,
> no luck so far.
>
> Thanks in advance
>
> __________________________________________________________
> 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