newbie question - executing system commands

Terry Byrne TerryByrne1963 at yahoo.com
Tue Sep 4 10:50:22 EDT 2001


I've had good luck with this combo...

    cmdPipe = os.popen(aCmdLine)
    resultStream = cmdPipe.read()

At this point you can look through resultStream for any error codes
that may have been returned by the command line process. Good luck!

HTH,

Terry


"Borzoj" <borzoj at pingu.ii.uj.edu.pl> wrote in message news:<9n23h1$qsc$1 at news.formus.pl>...
> I'm newbie both in shell scripting and pyhon so please be kind :)
> What would be the Python equivalent for following shell code:
> 
> for IMAGE_NAME in `ls`; do {
> #processing of $IMAGE_NAME
> };done
> 
> 
> ...or in other words what is the easiest way to execute shell
> command/external program from python and
> get access to it's output?
> 
> thx
> ____________
> This will be your new motto: dance like it hurts, love like you need money,
> work when pepole are watching.
> Dogbert



More information about the Python-list mailing list