So I have this script (nettest.sh) with the following code:
#!/bin/bash
# Internet Check
linktest="$(ping -c 1 google.com)"
if [[ $linktest != *"not"* ]]; then
echo -e " PASSED "
echo -e " $linktest "
else
echo -e " FAILED "
echo -e " $linktest "
fi
The result of the ping in case it fails is as follows:
ping: google.com: Name or service not known
But this is not working. When I have a link, It shows the right message. But when the link is down, it keeps showing the PASSED message and shows the failed ping message.
Any ideas ? (Using Debian/Kali)