I am trying to run a set of bash script commands in a python program. I have to run the commands one by one and handle errors and exceptions for each command. For this purpose, I am using the subprocess
module with the call
function as bellow:
result = subprocess.call("echo testing", shell = True)
as expected this command prints "testing" and sets the value of result
to 0, meaning that the command was successfully executed. Or, in the case of following command:
result = subprocess.call("echso testing", shell = True)
it prints "/bin/sh: 1: echso: not found" and sets the value of result
to 127, meaning that the command echso
is invalid.
My qusetion is, where can I find a complete list of these error numbers with descriptions that I could use for error handling? So far, I found a list of exit errors as follows:
1: general errors
2: misuse of shell builtins (pretty rare)
126: cannot invoke requested command
127: command not found error
128: invalid argument to “exit”
128+n: fatal error signal “n” (for example, kill -9 = 137)
130: script terminated by Ctrl-C
Is this all, or do you know more error codes with descriptions?