Reputation: 195
How To loop this code:
if scp remote-host:~/myfile ./ >& /dev/null
then
echo "transfer OK"
else
sleep 20
fi
loop must every 20 sec check for file on remote host, if file appear loop have to exit.
Upvotes: 0
Views: 2880
Reputation: 86854
while true
do
if scp remote-host:~/myfile . &> /dev/nul
then
echo "transfer OK"
break
fi
sleep 30
done
Or, if you prefer something more compact:
while :; do
(scp remote-host:~/myfile . &> /dev/null) && break
sleep 30
done
echo "transfer OK"
Note that :
is a built-in null command with a zero (success) exit code.
Upvotes: 1
Reputation: 1023
Try:
while true
if scp remote-host:~/myfile ./ >&/dev/null;
then echo "transfer OK";
fi
sleep 20;
done
Upvotes: 1