Getting return code for a Python script invoked from a Linux shell script

Jeff McNeil jeff at jmcneil.net
Wed Sep 23 13:00:51 EDT 2009


On Sep 23, 12:51 pm, volcano <mark.gey... at gmail.com> wrote:
> Hi, folks,
> I have a Python script that is invoked by a shell script. I uses
> sys.exit() with a parameter within python.
>
> The calling script is using this line to get the return code:
> exit_code = !$
>
> but it fails to get it. What's wrong here? (I am no Linux guru)
>
> Thanks in advance
> Mark

Assuming Bash, you'll want $? instead. The '!$' construct is used to
pull the last argument of the previous command.  Also, if I remember
correctly, the history mechanism is disabled within shell scripts.

--
Thanks,

Jeff
mcjeff.blogspot.com



More information about the Python-list mailing list