Is there a ping-like program that will return false when a packet is lost?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
-1
down vote
favorite
I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.
Does anyone know of such a beast?
networking ping exit-code
add a comment |Â
up vote
-1
down vote
favorite
I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.
Does anyone know of such a beast?
networking ping exit-code
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.
Does anyone know of such a beast?
networking ping exit-code
I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.
Does anyone know of such a beast?
networking ping exit-code
asked Jul 18 at 14:30
Barton Chittenden
23217
23217
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
5
down vote
Yes, it is called ping
.
Try something like this (in bash):
while true ; do
if ping -c 1 10.202.15.54 > /dev/null ; then
echo "It works"
else
echo "It does not work"
fi
sleep 5
done
add a comment |Â
up vote
0
down vote
ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"
add a comment |Â
up vote
0
down vote
I'd do this, you'd get a log so you could run it over time and graph the result in excel.
#!/bin/bash
#Script to ping the IP after the gateway.
LOG="ping.csv"
TARGET="10.0.0.1"
while :
do
if `ping -c1 $TARGET > /dev/null `
then
STATUS="OK"
else
STATUS="FAIL"
fi
echo "`date +'%D %H:%M:%S'` : $STATUS "
echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
sleep 30
done
add a comment |Â
up vote
-1
down vote
Pretty simple:
$ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
Yes, it is called ping
.
Try something like this (in bash):
while true ; do
if ping -c 1 10.202.15.54 > /dev/null ; then
echo "It works"
else
echo "It does not work"
fi
sleep 5
done
add a comment |Â
up vote
5
down vote
Yes, it is called ping
.
Try something like this (in bash):
while true ; do
if ping -c 1 10.202.15.54 > /dev/null ; then
echo "It works"
else
echo "It does not work"
fi
sleep 5
done
add a comment |Â
up vote
5
down vote
up vote
5
down vote
Yes, it is called ping
.
Try something like this (in bash):
while true ; do
if ping -c 1 10.202.15.54 > /dev/null ; then
echo "It works"
else
echo "It does not work"
fi
sleep 5
done
Yes, it is called ping
.
Try something like this (in bash):
while true ; do
if ping -c 1 10.202.15.54 > /dev/null ; then
echo "It works"
else
echo "It does not work"
fi
sleep 5
done
edited Jul 18 at 15:00
answered Jul 18 at 14:37
andcoz
11.5k32938
11.5k32938
add a comment |Â
add a comment |Â
up vote
0
down vote
ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"
add a comment |Â
up vote
0
down vote
ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"
add a comment |Â
up vote
0
down vote
up vote
0
down vote
ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"
ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"
answered Jul 18 at 14:43
alpha
1,241317
1,241317
add a comment |Â
add a comment |Â
up vote
0
down vote
I'd do this, you'd get a log so you could run it over time and graph the result in excel.
#!/bin/bash
#Script to ping the IP after the gateway.
LOG="ping.csv"
TARGET="10.0.0.1"
while :
do
if `ping -c1 $TARGET > /dev/null `
then
STATUS="OK"
else
STATUS="FAIL"
fi
echo "`date +'%D %H:%M:%S'` : $STATUS "
echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
sleep 30
done
add a comment |Â
up vote
0
down vote
I'd do this, you'd get a log so you could run it over time and graph the result in excel.
#!/bin/bash
#Script to ping the IP after the gateway.
LOG="ping.csv"
TARGET="10.0.0.1"
while :
do
if `ping -c1 $TARGET > /dev/null `
then
STATUS="OK"
else
STATUS="FAIL"
fi
echo "`date +'%D %H:%M:%S'` : $STATUS "
echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
sleep 30
done
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I'd do this, you'd get a log so you could run it over time and graph the result in excel.
#!/bin/bash
#Script to ping the IP after the gateway.
LOG="ping.csv"
TARGET="10.0.0.1"
while :
do
if `ping -c1 $TARGET > /dev/null `
then
STATUS="OK"
else
STATUS="FAIL"
fi
echo "`date +'%D %H:%M:%S'` : $STATUS "
echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
sleep 30
done
I'd do this, you'd get a log so you could run it over time and graph the result in excel.
#!/bin/bash
#Script to ping the IP after the gateway.
LOG="ping.csv"
TARGET="10.0.0.1"
while :
do
if `ping -c1 $TARGET > /dev/null `
then
STATUS="OK"
else
STATUS="FAIL"
fi
echo "`date +'%D %H:%M:%S'` : $STATUS "
echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
sleep 30
done
answered Jul 18 at 15:14
Joe M
5964
5964
add a comment |Â
add a comment |Â
up vote
-1
down vote
Pretty simple:
$ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"
add a comment |Â
up vote
-1
down vote
Pretty simple:
$ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
Pretty simple:
$ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"
Pretty simple:
$ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"
answered Jul 18 at 14:39
MysticDog
12
12
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457014%2fis-there-a-ping-like-program-that-will-return-false-when-a-packet-is-lost%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password