This particular script doesn't have any practical value. I'm just trying to get better at KSH scripting as that and bash are what are predominantly used in my work environment.
The goal of the script is to repeat the if...then command 5 times. However, when I called the script to run it, it simply doesn't load at all - no output. I have to ^C to end the process. I ran the if...then command independently of the for loop in a different script and it worked as desired.
I'm still fairly new to scripting, so bear with me here. Also, I will say that I did try this as a while loop with the same result.
Please see the code below and let me know if you have any questions. I'm not sure what to do here. Thank you.
#! /bin/ksh
currentping=$( ping 8.8.8.8 | sed '/^PING/d;/^$/d;/^-/d;/transmitted/d;/^rtt/d' | awk '{print $7}' | awk '{print substr( $0, length () -3) }' | sed 's/\=//' )
for i in {1..5};
do
if [[ $currentping -lt 100 ]];
then
echo "Your ping is $currentping."
elif [[ $currentping -ge 100 ]];
then
echo "Your current ping, which is $currentping, sucks. Go find better internet!"
else
echo "Your connection sucks!"
fi;
echo $i
done
In addition, I ran ps and confirmed that the script is running, but no output.