Originally posted by: Mehrdad
Hi Gurus
We have recently migrated a bunch of shell scripts from Solaris 8 to AIX 5.3 .
The problem is we are experiencing some odd behavior with shell scripts on the new platform that we have no clue where they are coming from.
First of all the issues I'm explaining below are intermittent, and we can't always recreate the problem.
Issue 1) The process exit value gets lost in the next statement:
#!/bin/sh grep
"text" /a/file
if [ $? -eq
"0" ]; then
do something; fi
Eventually
$? does not always reflect the correct exit value of "
grep"; this is script is being called by a custom scheduler engine written in C and ported to AIX. the scheduler uses "
system()" function to execute the script.
The odd is script works perfectly fine when we call is from shell; but when it gets called from the C app, it fails to get the correct exit value intermittently.
The problem is not just with grep, we have had the same issue with oracle's sqlplus program.
Issue 2) I/O doesn't seem to be in sync in consecutive create and test statements:
#!/bin/sh ls -ntr /dir > filelist.lst
if [ ! -f
"filelist.lst" ]; then
do something; fi
The above script has a similar problem to the one in issue #1, the "
-f" test fails intermittently when the script gets called by AIX
cron daemon. We have never managed to get it fail when calling the script from within standard shell.
I'm not sure if it is something related to AIX AIO servers or shell implementation; but there's obviously something wrong in our setup that I'm seeking your advice for.
Thanks in advance.
#AIX-Forum