I am calling a python script from PHP.
The python program has to return some value according to the arguments passed to it.
Here is a sample python program,
That is correct use of exit(). See also: http://docs.python.org/library/sys.html
In PHP, you can execute a command and obtain the return code using exec
.
The manual for exec
says the third parameter is a variable in which the return code will be stored, for example
exec('python blibble.py', $output, $ret_code);
$ret_code
will be the shell return code, and $output
is an array of the lines of text printed to std. output.
This does appear to be an appropriate use for a return code from what you described, i.e. 0 indicating success, and >0 being codes for various types of errors.