473,587 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

regarding system function

Dear All,

In Php If I send a command to system function
then It will return 1 on success and 0 on failure. So
based upon that value I can to further work.

But In Python If I send a command to system
function then It will return 0 only for both
conditions(succ ess and failure). So What I need
to do for this. I want the result like php system
function.
regards
Prabahar
_______________ _______________ _______________ _______________ ____________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
Jul 19 '05 #1
1 1559
praba kar <pr*********@ya hoo.co.in> writes:
Dear All,

In Php If I send a command to system function
then It will return 1 on success and 0 on failure. So
based upon that value I can to further work.

But In Python If I send a command to system
function then It will return 0 only for both
conditions(succ ess and failure). So What I need
to do for this. I want the result like php system
function.


You don't say what platform you're on, but from your description of
the problem, it's not Unix:

py> os.system("grep foo /dev/null")
256
py> os.system("grep foo /no_such_file")
grep: /no_such_file: No such file or directory
512

os.system is a simple wrapper around the C system() function. It's
return value is the same as that function. On unix, that's the 1/0 you
want in the upper byte, and status information in the lower byte - so
you divide by 256. I have no idea what Windows does in this case.

I'd recommend using the subprocess routines instead of os.system. They
are much more powerful/flexible than os.system.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #2

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

Similar topics

1
1449
by: Mosas | last post by:
Dear All, Php has exec function to run system commands and this function return last line of system command result. But in Python I can see only os.system() function to run system command but it doesn't return any result like php exec function. I want to know about php equivalent exec function in Python. So If anyone know regarding this...
0
1584
by: Paul Hsieh | last post by:
"Paul D. Boyle" <boyle@laue.chem.ncsu.edu> wrote: > There was a recent thread in this group which talked about the > shortcomings of fgets(). I decided to try my hand at writing a > replacement for fgets() using fgetc() and realloc() to read a line of > arbitrary length. I know that the better programmers in this group could > write a more...
3
2981
by: Marcelo | last post by:
Hello, I am trying to create a postback event, and it is working, just not calling the sub. I have a datagrid which has <asp:DataGrid id="Mensajes" ... <Columns> <asp:HyperLinkColumn ....
3
1561
by: Aaron | last post by:
Why do my session values return to nothing on post back? I want to click a button and have the row, as in: dataset.table(0).rows(THIS ROW NUMBER IS WHAT I AM TALKING ABOUT), either increment or decrement to facilitate a movenext and movelast. I have been pulling my hair out and am at the end of my rope. PLEASE, how should I implement...
1
1305
by: Terrance | last post by:
Hello, I was wondering if someone can help me understand something. Below is some code that I got from the MS website that is suppose to authenticate for the username and password on the local machine. I tested this code in VB.net 2003 in a WINDOW FORM class and it seems to work fine. However, when I test it in VB.net 2005 Express Edition it...
8
2319
by: AG | last post by:
Hello, This is my first post to this group, and on top of that I am a beginner. So please direct me to another group if this post seems out of place.... I have recently written a program which calculates loan amortization schedules, writes the data to a text file, and then upon user prompt, the program will display the created file and...
12
2058
by: sunil | last post by:
Hi All, Please have a look the below program #include<stdlib.h> int i = system("pwd"); I compiled the above program in UNIX ,it got compiled and executed with out any errors.It prints the present working directory.Am having certain doubts about this program.
4
2301
by: Benny Van | last post by:
Hi all! I have a question regarding a windows operating system function: I was asked to write a small program for a homework to display the user name and computer name and the system time out to a console window: the display would be like: Hello XXX(user) Today is XXX(date) The Time is XXX(current system time) I was asked to use a...
2
3787
by: somenath | last post by:
Hi All, I have one question regarding the alignment of pointer returned by malloc. In K&R2 page number 186 one union is used to enforce the alignment as mentioned bellow. typedef long Align; union header { struct {
0
7915
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...
0
7843
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...
0
8205
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. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
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...
0
3840
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...
1
2347
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
1
1452
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.