Animation Ping on Solaris Like Cisco Ping


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Animation Ping on Solaris Like Cisco Ping
# 1  
Old 12-03-2011
Animation Ping on Solaris Like Cisco Ping

Hi,

I develop simple animation ping script on Solaris Platform. It is like Cisco ping.

Examples and source code are below.
Code:
bash-3.00$ gokcell 152.155.180.8 30
Sending 30 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!.
% 93.33 success... % 6.66 packet loss...
Start:04-12-2011-03:53:17
End :04-12-2011-03:54:08


bash-3.00$ gokcell 152.155.180.8 60
Sending 60 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% 100.00 success... % 0 packet loss...
Start:04-12-2011-05:36:40
End :04-12-2011-05:37:44



bash-3.00$ more gokcell
#!/bin/bash
count1=0
count2=0
start=`date +"%d-%m-%Y-%T"`
#Developed by Goksel Yangin for STC Network 
echo
echo Sending $2 Ping Packets to $1
echo
for ((i=1; i<=$2; i++))
do
  sonuc=`/usr/sbin/ping -s $1 64 1 | grep packet | awk '{print $(NF-2)}'`
  sleep 1
  if [[ "$sonuc" == "0%" ]]
  then
    count1=`expr $count1 + 1`
    echo -n !
  else 
    count2=`expr $count2 + 1`
    echo -n .
  fi
done
end=`date +"%d-%m-%Y-%T"`
let "count1*=100"
#let "count1/=$2"
#let kalan=count1%$2 

let "count2*=100"
#let "count2/=$2"
#let kalan2=count2%$2

echo
num1=$(echo "scale=2; $count1 / $2" | bc) 
num2=$(echo "scale=2; $count2 / $2" | bc) 
#printf "\x1b[5m$num1..$num2\x1b[25m"
#echo -n % $num1 success... % $num2 packet loss...
echo -n "`tput blink`% $num1 success... % $num2 packet loss...`tput sgr0`"
echo 
echo Start:$start 
echo End :$end
echo

Regards,

Goksel Yangin
Computer Engineer

Last edited by Scott; 12-04-2011 at 07:44 AM.. Reason: Code tags, please...
# 2  
Old 12-04-2011
Tested in Linux:
Code:
#!/bin/bash 
#or ksh93
[ $# -lt 2 ] && echo "usage:$0 count dest " >&2 && exit 1

Cnt=$1
Dest=$2
Bold=$(tput bold )
BoldOff=$(tput sgr0 )
ok=0
notok=0

start=$(date '+%Y-%m-%d %T' )
echo "Sending $Cnt Ping Packets to $Dest"
i=1
while ((i<=Cnt))
do
        data=$(ping -n -c 1 $Dest | grep "1 packets transmitted" )
        case "$data" in
                *100%*packet*loss*)
                        ((notok+=1))
                        echo -n !
                        ;;
                *)      ((ok+=1))
                        echo -n .
                        ;;
        esac
        sleep 1
        ((i+=1))
done
echo
end=$(date '+%Y-%m-%d %T' )
((success=ok*100 / Cnt ))
((loss=notok*100 / Cnt ))
echo "$Bold % $success success... % $loss packet loss... $BoldOff"
echo "$start - $end "

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

2. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

3. Solaris

Solaris 10 - ping network issue

Hi, I'am begineer in this OS. I've installed it few days ago only to perform project "Managing users in Solaris". I have to create two virtual systems in eg. vmware , connect them and eg. rlogin from user1/machine1 to user2/machine2, give them some permissions to write read etc (this is... (1 Reply)
Discussion started by: michael.pelc
1 Replies

4. Solaris

Unable to ping Solaris VM from Xp host

Hi All, I am using Vmware Workstation 6.0.3 build-80004. Guest OS: Solaris 10 Host OS : Win XP I am getting request time out when i am trying to ping from XP ( cmd line) to Solaris VM - I have assigned IP 192.168.50.5 in Solaris VM ( Hostname: Tower1) and it is in UP status. ... (4 Replies)
Discussion started by: saurabh84g
4 Replies

5. Solaris

solaris ping timeout

Hi, I have two solaris 9 servers on the same switch, primary int0: 10.35.65.51 int1: 10.35.65.53 warm standby int0: 10.35.65.52 int1: 10.35.65.54 Primary server communicates with the other for db replication on int0 interfaces. But meanwhile we are using web interface running... (8 Replies)
Discussion started by: magnimious
8 Replies

6. Solaris

Ping Sun Solaris 10 on VmWare

Hi, i installed Sun Solaris 10 on VmWare Workstation 6.5 on my Windwos Vista PC. I would to ping solaris virtual machin froma my pc, but i can't do that. Can help me?! I'm sorry for my bad English. akela87 (2 Replies)
Discussion started by: akela87
2 Replies

7. Solaris

Can not ping from Solaris VMWare to Windows

Dear All, I have installed Sun Solaris 10 on VMWare 6.5 completely and i have configured IP address already. Solaris's IP Address (on VMWare) is 192.168.10.241 and Windows xp that contain VMWare IP address is 192.168.10.125, but when i ping from solaris to my windows it didn't response at all.... (3 Replies)
Discussion started by: veasnabee
3 Replies

8. Solaris

Can't ping using hostname on Solaris 10

I recently installed Solaris 10 on my Sun workstation. I cannot ping using hostname from another computer on the same network. But I can ping using the IP address. Also I can ping other systems using their hostnames. Can anyone give some information regarding how to resolve this issue. (4 Replies)
Discussion started by: alpha123
4 Replies

9. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

10. UNIX for Advanced & Expert Users

Solaris Based Ping Sweeper

good morning, anybody know of a good Freeware ping sweeper for Solaris, I've been given the job of finding active IP's on the network, would like a tool which can search for range or address's do you know of anything cheers Kie (2 Replies)
Discussion started by: kie
2 Replies
Login or Register to Ask a Question