On Oct 15, Casey Bralla wrote:
> How do I return text from a standard Linux command?
> 
> For example:  I want to read the stdout results of a typical linux
> command (such as "df") into a Python variable.

>>> from os import popen
>>> p = popen("df")
>>> p
<open file 'df', mode 'r' at 0xf6f685e0>
>>> df_out = p.read()
>>> p.close()
>>> p
<closed file 'df', mode 'r' at 0xf6f685e0>
>>> print df_out

-- 
Micah Elliott
<[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to