Computing.Net > Forums > Unix > unix script exit status

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

unix script exit status

Reply to Message Icon

Name: yy1
Date: May 10, 2006 at 02:04:31 Pacific
OS: HP-UX
CPU/Ram: -
Product: -
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 10, 2006 at 13:54:14 Pacific
Reply:

Not having your executable, I can only guess, but have you tried surrounding the whole command in double quotes:

ksh -c "/proj/proj.exe 2>> /tmp/run.log 1> /tmp/error.log << !
^M
!"

Maybe the ksh -c being spawned doesn't know what to do with stdout and stderr.

Two other observations:

1) ^M is an actual carriagle return?

2) Based on the file names, don't you really mean this:?

2>>/tmp/error.log 1>/tmp/run.log


0

Response Number 2
Name: yy1
Date: May 10, 2006 at 18:41:52 Pacific
Reply:

Yes, ^M is an actual carriagle return.

I have tried the following, but still having the exit code as 1 instead of 100:

To put the whole command in double quote:

ksh -c "/proj/proj.exe 2>>/tmp/error.log 2>/tmp/error.log" << !
^M
!

Any other clue to solve this?



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Passing control char - un... test argument



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: unix script exit status

fail exit status for telnet script www.computing.net/answers/unix/fail-exit-status-for-telnet-script/6524.html

help redoing unix script student db www.computing.net/answers/unix/help-redoing-unix-script-student-db/5151.html

UNIX Script Prob. www.computing.net/answers/unix/unix-script-prob/2039.html