"Lawrence Shafer" <[EMAIL PROTECTED]> wrote

> Why doesn't this fill otp with the output of ls?? (I know python has
> it's own file tools, I'm just playing around ;)
>
> otp=os.system(cmd)

Because os.system returnsd the exit status of the command.
zero means the command executed OK anything else is an
error code.

To get the output you need to read stdout or stderr.

To do that, the current preferred mechanism is via the
subprocess module which replaces os.system/os.popen/commands
os.spawn etc etc.

The documentation has examples.

Also my web

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld tutor at the end of the OS 
topic has examples
of subprocess.Popen as well as the older methods.

HTH,


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to