Apr 2, 2008

2nd shell scripting (Basic)

erm, this morning while I arrived at my office, the internet connection was down. It was down because of the electricity trip last night while we do the network cabling at the office. So without internet i wonder what else can i do.

So I started to open up text editor, and try do make some script. I remember 'slamdunk' once told me, the way to troubleshoot network problem and he using shell script to make his life easier. So I try to recall back his way of doing it, and here is what I come up with:
#$1 is an IP address
while :; do
echo "$x)---> Ping Internet Protocol : $1 --->"
echo " <-------- Ping Reply is => `ping -c1 -s1 $1 | grep "1 \
received" | cut -d "," -f2` \
<--------||" x=`expr $x + $y` echo " " sleep 10 done
So here is what i did and the outcome is nice. I only see if the destination is reachable or not instead of all the ttl, ms and etc. So all I output is only the one I would like to get from the ping command.

After finish writing this script, I try it on my laptop to ping google and it works where i only manage to see the output either reachable or unreachable. :) Nice one for beginner right?

how to use this script? you just need to write sh [script] [ip/url]

Thank you for your unbelievable support on Negative Zero - Permission to read and write blog for nearly 4 years. Don't forget to like Negative Zero on Facebook.
Blogirific.com Blog Directory

Post(s) you might like to read :



Post a Comment