1

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
2
  • does s2 return success? try echo "copy done, ret code $?" Commented Jan 14, 2011 at 10:23
  • Does s2 have anything to the file referred to be $tempfile, e.g. overwrites it? Commented Jan 14, 2011 at 10:59

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

You mean the content of s2? or its output? s2 is pretty big.
@Johnyy: The content. Somewhere there is a cat or ssh or something similar that is chewing up the input.
ssh is doing it. Use ssh -n to prevent it from doing so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.