0

Alright, I think my previous post about this subject was very confusing so I will try again. First off I appreciate all the responses to my prior post (Setting a Variable to the Exit Code).

It is my understanding that when a script completes it returns an exit code. I want to capture this exit code in order to pass it to a CF page. So my questions are:

1) Is there an exit code returned when a script completes?

2) Is the value of the exit code stored somewhere? If so where?

3) Can I assign the value of the exit code to a variable?
i.e. errorlevel = exit code

4) Can I include the variable in my URL?
i.e. ('http://cob/gis/GISAutoProcess_Action.cfm?ProcessID=000&ErrorCode=%s' % (errorlevel))

5) Can this be added to the end of the process or does it need to be run separately?

6) If I need to run it separately is there a way to set a ‘global’ variable that can be called in the other process?

Thank you everybody for your patience and understanding as I stumble my way through my first Python experience.

2
Contributors
1
Reply
4
Views
11 Years
Discussion Span
Last Post by CrazyDieter
0

1) Is there an exit code returned when a script completes?

(module sys) :
exit( [arg])

Exit from Python. This is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level. The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. If it is an integer, zero is considered successful termination'' and any nonzero value is consideredabnormal termination'' by shells and the like. Most systems require it to be in the range 0-127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors. If another type of object is passed, None is equivalent to passing zero, and any other object is printed to sys.stderr and results in an exit code of 1. In particular, sys.exit("some error message") is a quick way to exit a program when an error occurs.
Is the value of the exit code stored somewhere? If so where?

This integer value is stored by the context that called the process (I mean the python interpreter). This can be a shell script, or a c function (the system() function, for example)

3) Can I assign the value of the exit code to a variable?
i.e. errorlevel = exit code

No. (But I'm not sure i understand your question)

Edited by pyTony: fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.