calling applications from python

Martin von Loewis loewis at
Thu Aug 9 19:19:46 CEST 2001

"Jesper Olsen" <jolsen at> writes:

> It is possible to call applications from a python program using, e.g.
> the os.system command:
> os.system("ls -l")
> Is it possible to attach the output from this command to a file?
> I would like to be able to read this output, instead of just sending it to
> stdout.

Certainly, that would be

p = os.popen("ls -l")
output =

Of course, if it is really ls(1) that you are after, I recommend to
use os.listdir instead, combined with os.stat.


More information about the Python-list mailing list