I want to use the wget command to download a file from a webpage and if just in case the file is empty the script should repeat the wget command.
something like this
wget -q -O - http://www.someurl.something > /tmp/file
if [[ -s /tmp/file ]] ; then
echo "$FILE has data." (Continue rest of the script)
else
echo "$FILE is empty." (Repeat the wget command until file contains data then continue rest of the script)
fi ;
It loops because the file does't contain any data, that's what you wanted.
It would be better to insert a
sleep 10 (or any other number of seconds) to avoid overloading (and possible banning of your IP) of the server. It would be better to put a maximum iterations (20 in the example below) in the loop for the same reason.
>/tmp/file
until [ -s /tmp/file ] || [ $I -gt 20 ]
do
wget -q -O /tmp/file www.someurl/something
let I+=1
sleep 10
done