Wouldn't the fork() command handle this?

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 e! ach 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

Reply via email to