Re: unix script exit status while calling informix program
Posted in 2006
Topics: General Discussion
Richard Harnden wrote: >> Hi, >> >> Can anyone tell me why I get the different exit status for the following >> script execution while calling the informix program (/proj/prog.exe) : >> >> Note: the unix are all written in KORN shell. > >As is good and proper. > >> Unix Script A >> ----------------- >> ksh -c "/proj/prog.exe " 2>>/tmp/run.log 1>/tmp/error.log << ! > >Don't you mean: 1>/tmp/run.log 2>>/tmp/error.log ? > >If those files already exist, does your current user have sufficient >permission? > >> ^M >> ! >[quoted text clipped - 14 lines] >> I am suppose to use method script A but how to get the correct return code in >> the unix script in this case? I have tried the following, but it gave a very funny result: Note: forget about the log file name, I might have put in wrongly in the earlier thread. Trying to redirect the output to a new file to prove that it is not the permission issue. Trying 1 ----------------- ksh -c "/proj/prog.exe " 1>/tmp/file1 2>/tmp/file2 << ! ^M ! ret_code=$? Result: the ret_code giving 1 while the correct code should be 100. Content of file2 is empty while file1 contains the standard output from the screen. Trying 2 --------------- ksh -c "/proj/prog.exe " 1>/tmp/file1 << ! ^M ! ret_code=$? Result: the ret_code giving 100 (which is the correct one). The content of file1 same as trying 1 above. Question: Why it is giving the correct result without the 2>/tmp/file2 ? Any idea? Please help. -- Message posted via http://www.dbmonster.com
On 5/10/06, yy4 via DBMonster.com <u21544@uwe.iiug.org> wrote: > Richard Harnden wrote: > >> Can anyone tell me why I get the different exit status for the following > >> script execution while calling the informix program (/proj/prog.exe) : > >> > >> Note: the unix are all written in KORN shell. > > > >As is good and proper. > > > >> Unix Script A > >> ----------------- > >> ksh -c "/proj/prog.exe " 2>>/tmp/run.log 1>/tmp/error.log << ! > > > >Don't you mean: 1>/tmp/run.log 2>>/tmp/error.log ? > > > >If those files already exist, does your current user have sufficient > >permission? > > > >> ^M > >> ! > >[quoted text clipped - 14 lines] > >> I am suppose to use method script A but how to get the correct return code in > >> the unix script in this case? > > > I have tried the following, but it gave a very funny result: > Note: forget about the log file name, I might have put in wrongly in the > earlier thread. > > Trying to redirect the output to a new file to prove that it is not the > permission issue. > > Trying 1 > ----------------- > ksh -c "/proj/prog.exe " 1>/tmp/file1 2>/tmp/file2 << ! > ^M > ! > ret_code=$? > > Result: the ret_code giving 1 while the correct code should be 100. Content > of file2 is empty while file1 contains the standard output from the screen. > > > Trying 2 > --------------- > ksh -c "/proj/prog.exe " 1>/tmp/file1 << ! > ^M > ! > ret_code=$? > > Result: the ret_code giving 100 (which is the correct one). The content of > file1 same as trying 1 above. > > Question: Why it is giving the correct result without the 2>/tmp/file2 ? Any > idea? > Please help. Given full-screen output, I4GL expects at least one of stdin, stdout and stderr to be a terminal, and may be getting upset that it cannot find one when you redirect all three. I'd investigate using truss or equivalent (strace, ...) and see whether there is a concrete indication of different exit points or exit statuses; I'm confident you'll find some indications. You might also poke around for an environment variable such as INFORMIXQATERM (strings -a prog.exe | grep INFORMIXTERM) and set it to ansi, say, and see whether that alters anything. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/