running a shell command from a python program

aurora aurora00 at gmail.com
Wed Feb 23 13:25:32 EST 2005


In Python 2.4, use the new subprocess module for this. It subsume the  
popen* methods.

> Hi,
>    I'm a newbie, so please be gentle :-)
>
> How would I run a shell command in Python?
>
> Here is what I want to do:
> I want to run a shell command that outputs some stuff, save it into a
> list and do stuff with the contents of that list.
>
> I started with a BASH script actually, until I realized I really needed
> better data structures :-)
>
> Is popen the answer? Also, where online would I get access to good
> sample code that I could peruse?
>
> I'm running 2.2.3 on Linux, and going strictly by online doc so far.
>
> Thanks!
> S C
>




More information about the Python-list mailing list