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

V

volcano

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
 
I

Igor Pozgaj

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)

Exit code is obtained with $?, not with !$
 
J

Jeff McNeil

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.
 
V

volcano

On Wednesday 23 September 2009 18:51:29 volcano wrote:> exit_code = !$

I think it's $? to get the code.
\d

Thanks to all who replied,
actually, it was $! ( brain 'copy-paste' failure:) ) and $? did the
job!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top