School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,167 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,543 people online right now. Registration is fast and FREE... Join Now!




SOLVED - Any way to make this faster?

 

SOLVED - Any way to make this faster?, Perl Ping Script

kingtomato117

30 Jun, 2009 - 05:03 AM
Post #1

New D.I.C Head
*

Joined: 5 Feb, 2009
Posts: 22

CODE
#! /bin/ksh
rm pingresults.txt
IPLIST=`cat ./pinglist.txt`
for ip in $IPLIST
do
echo $ip
ping -c 2 -s 1 $ip
if [ $? -eq 0 ]
then
echo $ip "Pings">>pingresults.txt
else
echo $ip "Powered off">>pingresults.txt
fi
done
echo DONE!


We upload it to a server and it pings a list. The problem is it only sends two packets and it seems to take forever to transmit those packets and report back. Is there a way I can do it and not have to lower the number of packets transmitted?

This post has been edited by kingtomato117: 30 Jun, 2009 - 06:36 AM

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 3)

chorny_cpan

RE: SOLVED - Any Way To Make This Faster?

30 Jun, 2009 - 05:08 AM
Post #2

New D.I.C Head
Group Icon

Joined: 13 May, 2009
Posts: 36


Dream Kudos: 25
My Contributions
This is not Perl - it has "#! /bin/ksh".

In general, you should set lower timeout.
User is offlineProfile CardPM
+Quote Post

kingtomato117

RE: SOLVED - Any Way To Make This Faster?

30 Jun, 2009 - 05:17 AM
Post #3

New D.I.C Head
*

Joined: 5 Feb, 2009
Posts: 22

QUOTE(chorny_cpan @ 30 Jun, 2009 - 05:08 AM) *

This is not Perl - it has "#! /bin/ksh".

In general, you should set lower timeout.



Its a .sh file. Is that a shell file?

EDIT: Also we're switching servers and the ping "layout" is different I guess? they just threw this code at me and I have no expereicne with hp ux which is what we're using.
The one we use now which is what the code above is for is:
$ ping
usage: ping [-LRdfmnqrtv] [-T ttl] [-I addr] [-c count] [-i wait] [-l preload]
[-p pattern] [-s packetsize] host|[!]@hop1@hop2@...[@|:]dst

The one we're changing to is:
Usage: ping [-oprv] [-i address] [-I interval] [-t ttl] host [-n count [-m time
out]]
ping [-oprv] [-i address] [-I interval] [-t ttl] host packet-size [[-n]
count [-m timeout]]

What do I need to change in
CODE
ping -c 2 -s 1 $ip
to make it work on the new server? I made some changes but just get....ping: cannot set multicast source interface: Can't assign requested address

This post has been edited by kingtomato117: 30 Jun, 2009 - 05:54 AM
User is offlineProfile CardPM
+Quote Post

kingtomato117

RE: SOLVED - Any Way To Make This Faster?

30 Jun, 2009 - 06:36 AM
Post #4

New D.I.C Head
*

Joined: 5 Feb, 2009
Posts: 22

Figured it out:
ping -I 2 $ip 10 -n 3 -m 3

Thanks
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:24PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month