473,320 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get correct exit code from Python

2
Hi Friend,

I write a linux shell script to call a python script inside. But I got a wrong exit code from Python exit code. The linux shell script as follows;

#!/bin/bash
MyPython.py
exit $?

After run the above linux script, I always got exit code 0. But autually the Python log file shows that its exit code is 256. In python script, use sys.exit(256).

My question is how linux script can get the correct Python exit code?
Thanks for your help.

Sunny
Sep 17 '06 #1
2 14799
kudos
127 Expert 100+
just a wild guess, maybe it have something to do that error codes are usigned bytes, i.e in the range [0,255], so that it interpret the exit value 256 as 0?



Hi Friend,

I write a linux shell script to call a python script inside. But I got a wrong exit code from Python exit code. The linux shell script as follows;

#!/bin/bash
MyPython.py
exit $?

After run the above linux script, I always got exit code 0. But autually the Python log file shows that its exit code is 256. In python script, use sys.exit(256).

My question is how linux script can get the correct Python exit code?
Thanks for your help.

Sunny
Sep 17 '06 #2
sunyao
2
Hi Kudos,

Thanks for your response. I will try using other value.
Thanks again.

Sunny
Sep 18 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Ivan Voras | last post by:
In a code such as: if len(sys.argv) < 2: print "I need arguments!" sys.exit(1) Is sys.exit() really a good choice? Is there something more elegant? (I tried return but it is valid only in a...
1
by: Mark McEahern | last post by:
Is there a straightforward way to get the exit code from a windows process? I want to write a script that runs a bunch of .sql files against SQL Server using osql. I want it to stop if there's...
0
by: Andrew Athan | last post by:
I have a python program (snippet below) which does not want to seem to die when I issue a sys.exit() inside the SIGTERM handler. The output below is generated as the result of sending several...
8
by: Mike Maxwell | last post by:
<vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should...
1
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm...
2
by: Anthon | last post by:
I have a small C program that restarts a python based server application if the exit value of the system("python -m pythonscript arg1 arg2 ...") is greater than 127 (using WEXITSTATUS on the...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
0
by: Matthew Fitzgibbons | last post by:
Matthew Fitzgibbons wrote: Here's a modified example that _almost_ works: #!/usr/bin/env python import code import time import threading
0
by: Gary Robinson | last post by:
In Python 2.5.2, I notice that, in the interpreter or in a script, I can exit with: exit() But I don't see exit() mentioned as a built-in function; rather the Python Library Reference says we...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.