 |
 |
Detecting C failure indication in tcsh shell
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
Can anyone explain how I can detect a failure indication (return 1) in OS X's tcsh shell?
I am using C.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status:
Offline
|
|
Check the $? variable after running the command.
|
|
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
Originally posted by Mactoid:
Check the $? variable after running the command.
I hope that this does not mak eme look like an idiot, but how would I go about doing that?
Thanx!
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2000
Status:
Offline
|
|
% echo $?
or
% echo $status
[Edit]
By the way, an exit value of 1 doesn't always denote failure. Some programmers use 1 to denote a special exit case, an expected exit, possibly indicating that the program made changes; 0 would mean nothing changed, or no changes were encountered. 2 is an unexpected error, the sort that deserves a sudden exit, because an important procedure failed.
(Last edited by fitter; Sep 9, 2002 at 08:13 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2000
Status:
Offline
|
|
% echo $?
or
% echo $status
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
Originally posted by fitter:
% echo $?
or
% echo $status
So I enter this:
% echo $status ./main
and I get
2 ./main
I replaced my <return 1> with a <return 2> so it looks as though I am getting the right output.
have I done it right?
Thanx again gang!
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status:
Offline
|
|
Originally posted by hadocon:
So I enter this:
% echo $status ./main
and I get
2 ./main
I replaced my <return 1> with a <return 2> so it looks as though I am getting the right output.
have I done it right?
Thanx again gang!
Though I have never done this, I would expect it to be:
% ./main ; echo $status
Then, main actually RUNS. It also runs right before you check the status.
|

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
Originally posted by Detrius:
Though I have never done this, I would expect it to be:
% ./main ; echo $status
Then, main actually RUNS. It also runs right before you check the status.
AWESOME! That works even better.
I now get
Goodbye, cruel world!
2
Thanx for all the great help gang, you rock!
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|