By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

The return code

P: n/a
Hi,

I am running one service in the python script eg like
"service httpd status".
If I execute this command in normal shell kernel, the return code is
3. But in the python script its return code is different, ie not 3, I
mean to say that return codes are differing.
But I want the return code 3 , not the other one. So, how can I achieve this?

Regards,
Devi.
Nov 13 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Nov 13, 6:15*am, "devi thapa" <devi.th...@gmail.comwrote:
Hi,

* * * * * I am running one service in the python script eg like
"service httpd status".
If I execute this command in normal shell kernel, the return code is
3. But in the python script its return code is different, ie not 3, I
mean to say that return codes are differing.
But I want the return code *3 , not the other one. So, how can I achieve this?

Regards,
Devi.
Are you looking for sys.exit( 3 )?
Nov 13 '08 #2

P: n/a
On Nov 13, 4:12 pm, Aaron Brady <castiro...@gmail.comwrote:
On Nov 13, 6:15 am, "devi thapa" <devi.th...@gmail.comwrote:
Hi,
I am running one service in the python script eg like
"service httpd status".
If I execute this command in normal shell kernel, the return code is
3. But in the python script its return code is different, ie not 3, I
mean to say that return codes are differing.
But I want the return code 3 , not the other one. So, how can I achieve this?
Regards,
Devi.

Are you looking for sys.exit( 3 )?
Or, are you executing "service httpd status" from within a Python
script and not getting the exit code you're expecting from the command
you've spawned? If this is the case, ensure the command is actually
executing.

Can you post the actual code?
Nov 13 '08 #3

P: n/a
Jeff McNeil <je**@jmcneil.netwrote:
>On Nov 13, 6:15 am, "devi thapa" <devi.th...@gmail.comwrote:
I am running one service in the python script eg like
"service httpd status".
If I execute this command in normal shell kernel, the return code is
3. But in the python script its return code is different, ie not 3, I
mean to say that return codes are differing.
[ ... ] are you executing "service httpd status" from within a Python
script and not getting the exit code you're expecting from the command
you've spawned? If this is the case, ensure the command is actually
executing.
Or possibly whatever they're using to get the exit code is using the
os.wait()-style value, such as

sts = os.system("service httpd status")

in which case the required value is sts >8 .

See http://docs.python.org/library/os.html#os.system .

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Nov 14 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.