1
I am creating a script similar to tracerouce, when I type an IP it plots the route to arrive at the final destination, but when the route reaches the destination, the while still continues, as I correct this problem, stop when arriving at the final destination?
#!/bin/bash
echo "Digite um IP: "; read ip
count=1;
while [ $count -lt 30 ]; do
ping $ip -t $count -c 1 | grep ^From | awk '{print $2}'
if [ $? -eq 0 ]; then
printf 'O salto é: '
else
echo 'Rota Indisponível'
fi
let count=$count+1;
done