This paste expires on 2023-07-27 04:08:40.830847. Repaste, or download this paste. . Pasted through web.

#!/bin/bash -x
output=$(tty)
function greptext { tee ~/.grep-ping_1.txt; }
ping -c 3 "$1" 2>&1 | greptext | tee "$output"
errors_rec=$(grep -c "0 received" ~/.grep-ping_1.txt)
errors_notreach=$(grep -c "not known" ~/.grep-ping_1.txt)
if [[ "$@" == "-h" ]] || [[ "$@" == "h" ]]; then
    echo "There's no  help menu - you're on your own kid. Enter a valid IP or domain name."
    exit 0
else
    echo "Argument is OK."
fi
if [[ $errors_notreach -gt 0 ]] || [[ $errors_rec -gt 0 ]]; then #[[ $errorsfound -gt 0 ]]; then
    echo "failure: check connection and verify IP address. Also review logs"
    echo ======================================
else
    echo ======================================
    echo "Successfully reached $1 without errors"
fi
Filename: None. Size: 774b. View raw, , hex, or download this file.