HI,
I am new to shell scripting and need help to modify this in order to ping multiple hosts to decide if the route should be changed. This a sample of a single host that works but I need at least two host to fail before it completes.
#!/bin/sh
MissPings=0
while true;
do
ping -c 1 1.2.3.4
# If pings return success connectivity, the standard output ($?) will be set to zero
if [ $? -eq 0 ]
then
echo "Ping Success"
# If pings fail or timeout, increase the MissedPings variable by one
else
(( MissPings++ ))
echo $MissPings
fi
# If MissPings reaches five, edit the VPC main Route Table below subnets to forward traffic
# eni-123 (the spare vMX Elasitc Network Interface), and exit the script
if [ $MissPings -eq 5 ]
then
`aws ec2 replace-route --route-table-id xyz --destination-cidr-block 192.168.1.0/24 --network-interface-id ENI-123`
break
fi
sleep 1
done
I am new to shell scripting and need help to modify this in order to ping multiple hosts to decide if the route should be changed. This a sample of a single host that works but I need at least two host to fail before it completes.
#!/bin/sh
MissPings=0
while true;
do
ping -c 1 1.2.3.4
# If pings return success connectivity, the standard output ($?) will be set to zero
if [ $? -eq 0 ]
then
echo "Ping Success"
# If pings fail or timeout, increase the MissedPings variable by one
else
(( MissPings++ ))
echo $MissPings
fi
# If MissPings reaches five, edit the VPC main Route Table below subnets to forward traffic
# eni-123 (the spare vMX Elasitc Network Interface), and exit the script
if [ $MissPings -eq 5 ]
then
`aws ec2 replace-route --route-table-id xyz --destination-cidr-block 192.168.1.0/24 --network-interface-id ENI-123`
break
fi
sleep 1
done