Johnyy
Johnyy

Reputation: 2116

Shell script exiting the loop after calling another script

I have a shell script s1 calling another script s2 in a loop.

However s1 can not seem to continue the loop after s2 returns.

Commenting out the line that calls s2 will enable the loop to continue.

s2 does copy of one file, s1 checks conditions and copy several files using s2.

Can anyone give a pointer what is going on here?

...
while read line
do
    s2 param1 param2 param3
    echo "copy done"
done < $tempfile

echo "out of loop"
...

"copy done" is printed, so is "out of loop"

Some contents in s2:

if ls -l $LOGDIR | grep -w sftp.log

if ssh $USER -i $IDENTITY "ls -l $MOV_LOC"

cat $TMPDIR/$TMPFILE1 | /usr/xpg4/bin/awk -v logdir=$LOGDIR -v register=$REGISTER -v rmt_cmd=$RMT_CMD -v identity=$IDENTITY '{print "scp -q -r -P 22 -i", identity, rmt_cmd ,$NF, ">>" , logdir "/" register , "2>&1"}' > $TMPDIR/$TMPSCRIPT2

cat $TMPDIR/$TMPFILE1 | /usr/xpg4/bin/awk -v tmpdir=$TMPDIR -v list=$TMPFILE2 '{print "digest -a sha1" , $NF , ">>", tmpdir "/" list}' > $TMPDIR/$TMPSCRIPT1

ssh $USER -i $IDENTITY "mv $REMOTE_QUEUE $MOV_LOC" > $TMPDIR/$TMPFILE5

Upvotes: 1

Views: 1333

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

Somewhere within s2 you have a command that is consuming stdin and therefore the redirection from $tempfile. Without seeing its contents we can't help further.

Upvotes: 3

Related Questions