20 lines
479 B
Bash
20 lines
479 B
Bash
#!/bin/bash
|
|
|
|
# This script will ping 8.8.8.8 and return the result
|
|
# If the ping is successful, it will return "OK"
|
|
# If the ping fails, it will return "ERROR"
|
|
|
|
# Send the ping command and store the output
|
|
ping_output=$(ping -c 1 8.8.8.8)
|
|
|
|
# Check if the output contains "0% packet loss"
|
|
if echo "$ping_output" | grep -q "0% packet loss"; then
|
|
echo "Content-type: text/plain"
|
|
echo ""
|
|
echo "OK"
|
|
else
|
|
echo "Content-type: text/plain"
|
|
echo ""
|
|
echo "ERROR"
|
|
fi
|