Bash script that will wait for a network connection
-
#!/bin/bash
-
-
PINGDEST=8.8.8.8
-
-
echo "Waiting for ping response from ${PINGDEST}"
-
-
COUN=1
-
while true; do
-
printf "."
-
ping -c1 ${PINGDEST} > /dev/null && break;
-
sleep 1
-
COUN=${COUN}+1
-
if [[ ${COUN} -gt 10 ]]; then
-
printf "\n"
-
echo "ERROR timed out wiating for ${PINGDEST}"
-
exit 1
-
fi
-
done
-
printf "\n"
-
echo "Ping recieved"
-
exit 0
RJM Article Type
Quick Reference