[Tutor] so.system() return values

Gus Tabares gus.tabares@verizon.net
Fri Jun 13 00:04:01 2003


>Hello all:
>    I am using os.system to execute shell commands on
>Linux 2.4.7-10 (RH 7.2). Implementation will be on
>RH 9.0 server.

>It appears from tests that os.system(cmd) returns a
>0 if successful and non-zero if not. This would be
>consistant with C system() call.

>Am I correct? Are there any gotchas? Is there documentation
>that I can be pointed to?


The best place to check information on standard Python modules is on
Python's website:
The module index is located at
http://www.python.org/doc/current/modindex.html. From the index:

system(command)
Execute the command (a string) in a subshell. This is implemented by calling
the Standard C function system(), and has the same limitations. Changes to
posix.environ, sys.stdin, etc. are not reflected in the environment of the
executed command. The return value is the exit status of the process encoded
in the format specified for wait(), except on Windows 95 and 98, where it is
always 0. Note that POSIX does not specify the meaning of the return value
of the C system() function, so the return value of the Python function is
system-dependent.


I guess that last line really answers your question:)

HTH,
Gus



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