Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > regarding system function

Reply
Thread Tools

regarding system function

 
 
praba kar
Guest
Posts: n/a
 
      04-22-2005
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(success 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
 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      04-22-2005
praba kar <(E-Mail Removed)> 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(success 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 <(E-Mail Removed)> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding system function sunil C Programming 12 10-09-2006 11:05 AM
Beginner question regarding the use of system() commands AG C Programming 8 04-23-2006 03:50 PM
Beta 2 question regarding System.Net.Mail Mantorok ASP .Net 0 08-18-2005 04:25 PM
System.Security.SecurityException: Error de solicitud de permiso de tipo System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Luis Esteban Valencia ASP .Net 0 07-14-2005 01:43 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments