Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Thread ??

Status
Not open for further replies.

user2base

Technical User
Oct 16, 2002
29
0
0
GB
I am writing a simple program using the Net::ping module to ping devices on a network. However, using a timeout of 1s per ping it's going to take 255 seconds to ping a class C.
Is there any way to split the IP range and run multiple pings in parrallel within my perl script ??

Thanks for your help as usual.
 
Hi there.

You need to look at fork() if you want to run multiple processes from your perlscript. Mike

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
An easier way is to ping the broadcast address for the subnet. Here's the script I use for our network.
Code:
$Cmd = "whosup";
$Usage = "USAGE: $Cmd subnet
Example: $Cmd 192.168.44";
if ($#ARGV < 0) {
    print &quot;$Usage \n&quot;;
    exit(1);
}
$Net = $ARGV[0];
$Broadcast = $Net . &quot;.255&quot;;

@Out = `ping -b $Broadcast -c 2 2>&1`;
foreach $Line (@Out) {
    next unless ($Line =~ m/${Net}.(\d+)/);
    $Up{$1} = 1;
}

print &quot;The following are up on $Net\n&quot;;
foreach $Key (sort {$a <=> $b} keys %Up) {
    print &quot;$Key, &quot;;
}
print &quot;\n&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top