os.system question

Ben Finney bignose-hates-spam at and-zip-does-too.com.au
Wed Jun 4 22:53:43 EDT 2003


On Tue, 03 Jun 2003 13:18:01 +0300, Ruslan Spivak wrote:
> I need to get result from 'ping' command(in manpage they are 0, 1, 2),
>[...]
> res = os.system("ping -w 3 192.168.1.1")
>
> This gives 256 or another numbers, what am i doing wrong?

The exit code returned to a parent when a child exits is defined by the
underlying operating system.  In the case of Unix, the parent gets a
16-bit number containing both the process ID that killed the child, and
the child's exit() value.

  <http://python.org/doc/current/lib/os-process.html>

Read the description of the system() function, which will refer you to
the wait() description, for an explanation of the exit code.

-- 
 \     "I must say that I find television very educational. The minute |
  `\   somebody turns it on, I go to the library and read a book."  -- |
_o__)                                                     Groucho Marx |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B




More information about the Python-list mailing list