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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exit status

Status
Not open for further replies.

yy2

MIS
May 3, 2006
10
0
0
US
Hi,

Can anyone tell me why I get the different exit status for the following script execution:

Script A
----------
ksh -c "/proj/prog.exe " 2>>/tmp/run.log 1>/tmp/error.log << !
^M
!
ret_code=$?

Script B
--------
ksh -c "/proj/prog.exe " << !
^M
!
ret_code=$?

Why am I getting different exit status (ret_code) from script A and script B?

The correct return code should be from the program - prog.exe which is 100, but I am getting exit status as 1 in script A ? Why?

I am suppose to use method script A but how to get the correct return code in this case?





 
Hi,
what does the ! in lines 3 of both scripts mean? ! in general is the negation operator and, used alone, always returns false. The : (the nop operator) always returns true.
 
this is a so called here script, you can sub ! by eg HERE

ksh -c "/proj/prog.exe " << HERE
^M
HERE
ret_code=$?

Best Regards, Franz
--
UNIX System Manager from Munich, Germany
 
in general, if you mean "HERE" you should say "HERE" or anything meaningful. If (and only if) you mean "not" you should say "!".
 
yep, full ack! At least it would improve the readability, not sure if it changes the fact, that yy2 get's different returncodes

Best Regards, Franz
--
UNIX System Manager from Munich, Germany
 
and to answer the original question:
Most probably there is no write permission to the log files /tmp/run.log or /tmp/error.log.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top