473,698 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program return value ?

Hi all, I'm trying to get the exit code of a program
I want to exec in a python script in a portable manner.

I've read that both os.system and os.spawnl are not a
portable solution.

I tried the os.popen() function and I got the program's exit
code with the close() method.

p=os.popen("ret urn_a_exit_code .sh")
retval=p.close( )

The only problem is that it doesn't return negative values.

What is your experience with that ?

Thanks in advance.

Jul 18 '05 #1
1 1755
George Marshall wrote:
Hi all, I'm trying to get the exit code of a program
I want to exec in a python script in a portable manner.
(...)
The only problem is that it doesn't return negative values.


On a Unix system, the exit status from a program is one byte, which on
8-bit systems can have values from 0 to 255. So if the program does
exit(-1), the exit status is (unsigned char)-1 == 255.

I don't know how this works on other operating system, but in any case I
imagine your problem is with the possible range of the exit status, not
with python. Maybe your program should write a value to stdout (or some
other file) instead, so python could read the number.

--
Hallvard
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1957
by: John Cho | last post by:
/* This program is a database program that will store video tape names, minutes, year released, and price I want it to be professional so that *YOU* will want to buy it and use it for a video store, j/k about that but i want it to be professional */ // note to leor, display works fine, you must have // pressed update #include<iostream>
1
4661
by: Tony Johansson | last post by:
Hello experts! As this program is now it's works perfectly when running as a application or as an Applet. Now to my question if I just change this row "public class Converter extends Applet " in class Converter below that it extends from a Frame instead from an Applet then the whole program krasch with message "An exception 'java.lang.IllegalArgumentException' has occured in ... I mean that if I run this program as an application I...
9
2351
by: santosh | last post by:
Hello all, I've put together a small program to count the number of characters and 'words' in a text file. The minimum length of a word, (in terms of no. of characters), as well as word delimiting characters can be specified on the command line. The default delimiting characters built into the program are space, newline, tab, carriage return, form feed, vertical tab, comma and null. If a 'u' or 'U' is specified as the last command line...
2
1591
by: duncanblacksmithmath | last post by:
I know a lot of you have seen this before but I have worked on the program and have gotten it to work thus far but I need help getting these two functions to work and implementing them. Here is what I have been trying to work out for these functions but can't get them to fully work out for me. information: A function to access an element of a list by its index called access i(LL, i). It traverses the list LL and returns the address of...
18
3129
by: ben.carbery | last post by:
Hi, I have just written a simple program to get me started in C that calculates the number of days since your birthdate. One thing that confuses me about the program (even though it works) is how global variables and function returns work... For example, I have a global array "char datestring;" which is defined in the function speakdate. speakdate just converts a set of integers (date variables) to a string.
9
6895
by: ehabaziz2001 | last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal program termination" E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01 Enter a number : 25 More numbers (y/n)? y Enter a number : 30 More numbers (y/n)? n
2
3972
by: zaidalin79 | last post by:
Here is my Inventory program for my Java class.... //Inventory.java //Class created to store item information for Inventory purposes //Created November 15, 2006 //Modified November 29, 2006 //Audrey A. Paige //IT315 class Product
4
12217
by: sallyk07 | last post by:
The question says: Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Create a program that deals 20 random cards. this is the card class i made but i dont know if it right...i also don't know how to creatre a program that deals random cards. public class Card { public final static int spades = 0,hearts = 1, diamonds = 2, clubs = 3; public final...
1
2512
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to start it and what main topics in C I will need to cover in the assignment. Thanks a lot. CSC180 Assignment #3: Menu Madness Due Date: Thursday, November 8th at 1:00am Contents: · General Info · What to Hand In o Submission Instructions
6
3259
by: APEJMAN | last post by:
I know what I'm posting here is wired, but it's been 3 days I'm workin g on these codes, but I have no result I post the code here I dont wanne bother you, but if any one of you have time to read my program I appriciate it. the program suppose to print a message on the screen #include <iostream> #include <string>
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.