Why does rexec cause while loop to end prematurely?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why does rexec cause while loop to end prematurely?
# 1  
Old 02-23-2005
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
# 2  
Old 02-23-2005
Your rsh should have a -n option. Use it.
# 3  
Old 02-23-2005
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!

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

End of file with while loop

(sh shell) I have a function I am using that does a date calculation so I can subtract dates. get_JD () { bc << MSG scale=0 date calculation ………....... MSG } Then I have this little script that runs after it. read XXX < TESTFILE pastdate=`get_JD $XXX` currdate=`get_JD &YYY`... (2 Replies)
Discussion started by: nickg
2 Replies

2. Shell Programming and Scripting

Nested While loop doesn't end

Hi, Below is my script in which i am using nested while loop to read two files and move the files to a remote server. My issue is that the 2nd while loop doesn't stop executing and it keeps on executing. Can someone please let me know where i have gone wrong. myFile=$ESER_TEST_FILES ... (2 Replies)
Discussion started by: funonnet
2 Replies

3. Shell Programming and Scripting

for loop two commands at the end

cat vfiler_volumes.list | while read var1 var2 ; do ssh -n "$var1" df -h "$var2" >> test this part works, however i would like to add an echo $var1 >> test before each ssh iteration. any pointers ? thanx (1 Reply)
Discussion started by: riegersteve
1 Replies

4. UNIX for Advanced & Expert Users

script dies prematurely and unpredictably

Hi, I have over 5 gb of data in a files structure in which month folders are in year folders, day folders are in month folders, and individual climate stations are in each day. I am trying to extract precipitation measured at 5 minute intervals for a duration of 15 years, but the script never... (2 Replies)
Discussion started by: mlw63@me.com
2 Replies

5. Infrastructure Monitoring

Nagios escalating prematurely

We are currently using Nagios 1.3 .The issue we facing is , when a alert is in Warning state and then from Warning it moves to Critical state ,the alert is escalated directly to L2,L3 L4 escalations,here nagios assumes that the time period ,the alert was in warning state as unacknowledged time... (0 Replies)
Discussion started by: apatil
0 Replies

6. Shell Programming and Scripting

Why doesn't this loop end?

Simple script, takes an cmd line argument and counts down to 1. NUMBER=$1 # One argument must be provided, otherwise don't execute if then echo "Error. Enter one argument " exit 0 elif then echo " " fi # Integer value must be greater than zero while do echo... (6 Replies)
Discussion started by: Breakology
6 Replies

7. Programming

nanosleep returns prematurely, with return value 0

Hi, I have encountered the following problem on Solaris 10: I have a thread that is asleep on nanosleep (set to 24 hours). Something that happens on another thread, causes the nanosleep to exit, even though the time has not elapsed. The returned value is 0 (so it doesn't look like it... (1 Reply)
Discussion started by: MeMyself
1 Replies

8. Shell Programming and Scripting

Limits of FOR loop to go to end of File

Hi ALL:), I have a file for e.g. ajdflkj|dkj|djfj|go|123|4||||||||||||||89|101||||||||||||||| The length of file is not fixed. So wat the limits should be given in for loop to access till end of file???? Thanks in advance..... (2 Replies)
Discussion started by: rohiiit.sharma
2 Replies

9. Shell Programming and Scripting

End of loop condition required???

Hi i have a variable with lots of tokens seperated with spaces. e.g VAR="ABC DEF GHSD GHQS TUTSD JHDTQ QDHQ CDQKDGQ WQUTQD DQUTQD DQJGDQ QDTQD WDQUTQDU QDUGQD QDJGQD DQUTDUQ QDUIDTQ" i want to separate all of the above tokens and call a script with each of the token e.g sh script.sh <TOKEN>... (4 Replies)
Discussion started by: skyineyes
4 Replies

10. Shell Programming and Scripting

TCSH.need help.take input during a while/end loop

I am writting a script in csh and I am blanking out on how I code in the ability to process user input in the middle of a while/end loop. while(1) args.. end it is a simple script, and I want to add hotkey functions, like q to quit, z to zero counters, etc.. Google has not been very... (1 Reply)
Discussion started by: seg
1 Replies
Login or Register to Ask a Question