I have to test out some FTP issues and so I was looking at writing this script which will loop through x times, sleep a random number of seconds and continue. I am looking at samples and this is what I came up with but can't get it to run. Any ideas on what is wrong with the script?
#! /bin/bash
HOST='host'
USER='user'
PASSWD='password'
i=1
while [[ $i -le 25 ]]
do
echo "$i"
ftp -n -v $HOST << EOT
quote USER $USER
quote PASS $PASSWD
bye
x=$(( ($RANDOM % 4) + 1))
echo "Sleeping $x number of seconds";
sleep $x
let i=i+1;
EOT
done
exit 0
The heredoc end marker EOT
is in the wrong place. Correct it like here:
#! /bin/bash
HOST='host'
USER='user'
PASSWD='password'
i=1
while [[ $i -le 25 ]]
do
echo "$i"
ftp -n -v $HOST << EOT
quote USER $USER
quote PASS $PASSWD
bye
EOT
x=$(( ($RANDOM % 4) + 1))
echo "Sleeping $x number of seconds"
sleep $x
let i=i+1
done
exit 0