Introduction:
This bash script helps you check internet connectivity by pinging a reliable host and reporting the response.
Code Snippet:
Instructions:
Run the script using these commands:
Example Output:
This bash script helps you check internet connectivity by pinging a reliable host and reporting the response.
Code Snippet:
Bash:
#!/bin/bash
# Network Connectivity Checker
HOST="8.8.8.8"
ping -c 4 $HOST > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Internet connection is active."
else
echo "No internet connection detected."
fi
Instructions:
Run the script using these commands:
Code:
chmod +x connectivity_checker.sh
./connectivity_checker.sh
Example Output:
Code:
Internet connection is active.