Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

What does "echo $?" return..

What does "echo $?" return..

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.

RE: What does "echo $?" return..

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 man program would tell you.


RE: What does "echo $?" return..

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!

RE: What does "echo $?" return..

What command did you run before echo $??
The return value is specified by the program, not the compiler or anything else.


RE: What does "echo $?" return..

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?????

RE: What does "echo $?" return..

I ran the cobol program i.e. CMPBDDYB
The program runs successfully..but when I enter echo $?
I get a 12.

RE: What does "echo $?" return..

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.

RE: What does "echo $?" return..

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??

RE: What does "echo $?" return..

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

RE: What does "echo $?" return..

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.

RE: What does "echo $?" return..

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.

RE: What does "echo $?" return..


that helps alot!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close