neeraj has asked for the wisdom of the Perl Monks concerning the following question:
Can u all suggest any solution to it. Is this some kind of synchronization problem. Any help would be greatly appreciated. Thanks Neeraj#! /usr/bin/perl use strict; use warnings; use Parallel::ForkManager; my @arr; my $PORT_NO = '80'; # Default port of HTTP my $SERVICE = "http"; my $pm = new Parallel::ForkManager(20); # At any instant maximum 20 pr +ocesses can run simultaneously my $ip; # Stores the IP address suppli +ed by user if (!$ARGV[0]) { print "Program intended to check the machines where webserver is r +unning. \n"; print "USAGE: perl wst.pl [ip(xxx.xxx.xxx)] \nInput only 3 octets +\n"; exit; } if ($ARGV[0] =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $ip = $ARGV[0]; } else { print "Enter IP in valid format (xxx.xxx.xxx) \n"; print "USAGE: perl wst.pl [ip(xxx.xxx.xxx)] \n"; exit; } foreach my $i (1..254) { my $ip_add = sprintf("%s.%s",$ip,$i); #print $ip_add; my $pid = $pm->start and next; my $val = `nmap -sT -p $PORT_NO $ip_add | grep $SERVICE`; #print $val; if ($val) { my $test = (split(/\s+/,$val))[1]; if ($test =~ m/open/) { #print "Web Server at $ip_add is running.\n"; push (@arr,$ip_add); #print "@arr\n"; } } $pm->finish; } print "reaping....might take some time\n"; $pm->wait_all_children; print "Web Server is running at : @arr \n"; exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parallel::ForkManager Problem
by broquaint (Abbot) on Jun 11, 2004 at 05:46 UTC | |
|
Re: Parallel::ForkManager Problem
by Zaxo (Archbishop) on Jun 11, 2004 at 05:37 UTC | |
|
Re: Parallel::ForkManager Problem (threads instead?)
by BrowserUk (Patriarch) on Jun 11, 2004 at 06:44 UTC | |
by Anonymous Monk on Jun 11, 2004 at 07:42 UTC |