I would need to with making while loop logic working in shell program when I am new into the shell programing
1) I would need to try to get the file from the remote side ----need to try 15 mins apart for 4 times and terminate the program if file is not available....
I would need to know how I can setup counters to try in while loop ......
as I have sample at below. Please assist
==============================================
for file in $FILES; do
echo
echo "About to Retrieve $file from $SOU$SRDIR"
echo "via $proxy"
echo
err=1
while [ "$err" != 0 ]; do
ssh -x $proxy ftp "$SOU$SRDIR$file"
err=$?
if [ "$err" != 0 ]; then
echo "File transfer failed. Bummer. $err"
echo "Trying again in 15 minutes"
sleep 900
fi
done
echo " Retrieving file $file ..."
scp -p $proxy:~/$file .
chmod 666 $file
ls -l $file
ssh -x $proxy rm $file
done
for file in $FILES
do
echo "About to Retrieve $file from $SOU$SRDIR"
echo "via $proxy"
err=1
cnt =1
while [ $cnt -le 4 ]
do
ssh -x $proxy ftp "$SOU$SRDIR$file"
err=$?
if [ "$err" != 0 ]
then
echo "File transfer failed. Bummer. $err"
echo "Trying again in 15 minutes"
sleep 900
cnt=`expr $cnt + 1`
else
break;
fi
done
for attempts in one two three four;
REMAINING=
for file in $FILES; do
echo
echo "About to Retrieve $file from $SOU$SRDIR"
echo "via $proxy"
echo
if ssh -x $proxy ftp "$SOU$SRDIR$file"; then
echo " Retrieving file $file ..."
scp -p $proxy:~/$file .
chmod 666 $file
ls -l $file
ssh -x $proxy rm $file
else
echo "File transfer failed. Bummer. $err"
echo "Trying again in 15 minutes"
REMAINING="$REMAINING $file"
fi
done
case $REMAINING in '') break;; esac
FILES=$REMAINING
sleep 900
done