Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does "echo $?" return.. 1

Status
Not open for further replies.

krickb

Programmer
Nov 19, 2003
11
US
This is a simplification of my recent question:
I really want to know what is "echo $?" returning.
I get a 0 when all is well, but I have seen a 1, or a 12 also. They do not seem to be unix return codes.
I am executing a microfocus cobol program that has been compiled on Unix with the Pro-c Compiler.
Thanks
 
It depends on the program you are executing. Look in the source of the COBOL program to see what the return codes mean, or perhaps
Code:
man program
would tell you.

//Daniel
 
Daniel,
I have tried that already, I am fairly certain it is not a unix return code..
It is not in man. I just wondered if it was a common unix command or if it is unique to the compiler?
Thanks for your input though!
 
What command did you run before
Code:
echo $?
?
The return value is specified by the program, not the compiler or anything else.

//Daniel
 
If you are fairly certain it is not a unix return code, why don't you ask this question in one of the cobol forums?????
 
I ran the cobol program i.e. CMPBDDYB
The program runs successfully..but when I enter echo $?
I get a 12.
 
I just want to rule out unix as the cause... is "echo $?"
a common unix command? (I know that echo is, but what does $? mean?
Sorry if these questions seem stupid..I don't have much experience with unix and cobol together.
Thanks
KB
 
echo $? is a command to give you the exit status of the last command.

0 usually means success. 1 means failure. other returns depend on the process that didn't succeed. In your case, it looks like it is cobol??

 
Thanks very much bi...that is what I am looking for!
KB
 
Thank you.

I had seen that echo $? before. My Unix in a Nutshell book isn't with me now so I had to do a google to get the right meaning. The echo $? is for the Bourne shell. C shell uses something a little more logical: echo $status.
 
Try 3 scripts (a C program or whatever) with the last line:

1. exit 0 (or return 0 in a C program)
2. exit 1 (or return 1 in a C program)
3. exit 3 (or return 3 in a C program)

run each script and after each issue a echo $?....

you will see what "echo $?" does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top