En Wed, 13 Jun 2007 21:47:16 -0300, mike <[EMAIL PROTECTED]> escribió:

> Following piece of code can capture IOError when the file doesn't
> exist, also, other unknown exceptions can be captured when I press
> Ctrl-C while the program is sleeping(time.sleep). Now the question is:
> when I run the non-exist command, the exception cannot be captured.

> So far so good, then I changed the code to run a non-exist command
> "wrong_command_test"(commented the open and sleep lines), then the
> script printed:
> sh: wrong_command_test: command not found
> well Done

That's because it is not an exception, it is an error message coming from  
your shell, not from Python.
You can extract the exit status from what os.system returns (see the  
details on the docs for os.system); in particular, usually "command not  
found" is error 127
This is a list of more-or-less standard exit codes:  
http://www.faqs.org/docs/abs/HTML/exitcodes.html

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to