I ran into the same problem when scanning a large list
of ip addresses. The problem with just using fork() is
that you can kill the server with too many processes.

I used Parallel::ForkManager (from cpan).
Let's you specify how many simultaneous forks you want
to run, so as not to bork the server with too many
processes.



--- wjnorth <[EMAIL PROTECTED]> wrote:
> Group,
> 
> This will probably be an easy question. I have a
> script that takes a comma 
> delimited string of IP addresses as an argument and
> then proceeds to nmap 
> port scan each IP address. The problem is, I don't
> want to loop through 
> each string in a foreach loop, and then execute the
> system call after the 
> prior call returns successful or not successful.
> What I'd like to do is 
> basically take the string and if there are 5 IP
> addresses, kick off 5 
> parallel system executions, but I want to do it in a
> controlled fashion. 
> I'm sure something like the following would work:
> 
> $strg = $ARGV[0];
> @someary = split ',', $strg;
> 
> 
> foreach (@someary) {
>       $host = $_;
>       $scancmd = qq!nmap -sS -P0 -p 1-65535 -T 5 -O -oG
> ./$host-scan.txt $host!;
>       system ($scancmd)
> }
> exit 0;
> 
> And while that would work, I'm not so sure it will
> release each process and 
> go to the next variable in the array, or if it will
> wait until the command 
> completes, in fact I'm probably 100% sure it will
> wait for the system call 
> to finish prior to moving forward, which really
> makes the script slow.
> 
> So, what I'm looking for is some sort of parallel
> execution module that I 
> can reference to create multiple PID's and then
> manage each one to validate 
> success or failure of the command.
> 
> Thoughts?
> 
> -Wes 
> 
> _______________________________________________
> Perl-Unix-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs


=====
Anthony Ettinger
[EMAIL PROTECTED]
http://www.apwebdesign.com
Instant Messengers:
1) yahoo im: apwebdesign   2) aol im: apwebdesignxl
3) msn im: [EMAIL PROTECTED]   4) icq im: 659139

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to