Why does rexec cause while loop to end prematurely?

I have the following korn shell script which reads the contents of an ascii file and performs an rexec command based on the line that was just read from the ascii file. The ascii file contains 6 lines, thus, the while loop should execute 6 times. The problem is that the rexec command within the while loop is causing the loop to end once the bottom of the loop is reached. I have tested this by commenting out the rexec, in which all 6 lines of the ascii file are then processed. How can I get around the rexec causing the while loop to end prematurely before all ascii file records have been processed/read? I have also tried rsh and it does the very same thing! Here is the while loop from AIX 5.3:

#!/bin/ksh
while read BACKUP_ENTRY
do
APPLICATION=$(echo $BACKUP_ENTRY|cut -f 1 -d "#")
ORACLE_HOST=$(echo $BACKUP_ENTRY|cut -f 2 -d "#")
ORACLE_SID=$(echo $BACKUP_ENTRY|cut -f 3 -d "#")

# Determine if Export was successful
EXPORT_CHECK=`rexec $ORACLE_HOST "find /db_backups/$ORACLE_SID/export -name "export_${ORACLE_SID}_*
.log" -mtime -1 -exec tail -1 {} \; | grep unsuccessful"`

if [ "${EXPORT_CHECK}" = "" ]
then
echo "Success"
else
echo "Failure"
fi

done < /home/scripts/verify_backups_list.txt

Your rsh should have a -n option. Use it.

Perderabo -

Your suggestion worked! I opted to use the rexec instead of rsh so that I don't have to touch the rhosts file on each remote host. The man pages for rexec indicated that the -i switch prevents reading from stdin. I added the -i switch and now it works perfectly!!!!

Thank you very much!

:slight_smile: