os.popen() vs os.system()
Grant Edwards
grant at nowhere.
Wed Dec 22 09:51:39 EST 1999
In article <Pine.WNT.4.21.9912220944130.205-100000 at wks_3.e-shopwork.com>, Sposhua wrote:
>Newbie...
>
>From what I've deciphered, the only differences between os.popen() and
>os.system() are:
>
>a) popen automatically starts a new process while system only does it if you
> include an &
Under Unix both start a new process.
The important difference (as I understand it) is
popen lets you interact with the program by reading and writing pipes
while it's running.
system() is more of a batch mode thing, the program runs to
completion, then you get the return status.
>??? If so, what's the use of os.system()?
If you just want to run a shell command and don't need to
provide any stdin and don't care about stdout/stderr. For
example, if you just want to copy a directory tree from one
place to another:
status = os.system("cp -r srcdir /some/where/else")
If you want to start a program, send it input and/or watch its
output as it runs, then use popen().
--
Grant Edwards grante Yow! I just heard the
at SEVENTIES were over!! And
visi.com I was just getting in touch
with my LEISURE SUIT!!
More information about the Python-list
mailing list