[root@linux ~]# vim ping.sh
#!/bin/sh
host=$1
function pingcheck
{
ping=`ping -c 1 $host | grep bytes | wc -l`
if [ “$ping” -gt 1 ]; then
echo “HOST IS UP SAHIL”
else
echo “HOST IS DOWN SAHIL HAHAHHAHA”
exit
fi
}
pingcheck
wq!
Save and Quit.
Now Check
[root@linux ~]# chmod +x ping.sh
Example:- 1.
[root@linux ~]# ./ping.sh 192.168.11.222
HOST IS UP SAHIL
Example :- 2
[root@linux ~]# ./ping.sh 192.168.11.20
HOST IS DOWN SAHIL HAHAHHAHA
Enjoy Linux-Ing 🙂