Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

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.

krickb (Programmer) (OP)
1 Dec 03 14:46
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
danielhozac (Programmer)
1 Dec 03 14:51
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.

//Daniel

krickb (Programmer) (OP)
1 Dec 03 14:55
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!
danielhozac (Programmer)
1 Dec 03 15:04
What command did you run before echo $??
The return value is specified by the program, not the compiler or anything else.

//Daniel

Helpful Member!  bi (TechnicalUser)
1 Dec 03 15:04
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?????
krickb (Programmer) (OP)
1 Dec 03 15:19
I ran the cobol program i.e. CMPBDDYB
The program runs successfully..but when I enter echo $?
I get a 12.
krickb (Programmer) (OP)
1 Dec 03 15:25
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
bi (TechnicalUser)
1 Dec 03 15:46
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??

krickb (Programmer) (OP)
1 Dec 03 15:52
Thanks very much bi...that is what I am looking for!
KB
bi (TechnicalUser)
1 Dec 03 16:00
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.
Chacalinc (Vendor)
2 Dec 03 2:27
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.
krickb (Programmer) (OP)
2 Dec 03 10:36
Thanks..

that helps alot!

KB

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!

Back To Forum

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