|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Running multiple commands at once
Ok, i've got a good question, it might be really easy, but I haven't been able to figure it out.
I have a program that select a list of id's and ip addresses from a table (part of a database that holds apache web logs). It select the id and ip, then uses the perl module Net: NS to reverse resolve the ip. It take the hostname and TTL for that record, and updates the table with the new information. This works great, the only problem is, is that 1) it only resolves one ip at a time 2) it does a update to the database for every ip. and this table is growing fast (at about 3000 records right now) What I want to know, is how can I run multiple reverse lookups at the same time? Can I, using the Net: NS module, or any other way, open say 20 pipes/connections to the name server and lookup 20 ips at the same time? rather than one at a time?Thanks! Mike |
|
#2
|
|||
|
|||
|
are you leaving your connection to the database open as you select your information
open your database foreach $i (@IPS) { select information based on $i and dump into an array } close database parse out information from array and do whatever you want with the information. just let the loop build the array, and leave your database open until it is finished getting the information, then close it. |
|
#3
|
|||
|
|||
|
I dont' leave the database connection open, it loads the table into a hash (%hosts{tableid} = ipaddress
and disconnectsbut either way, I woul still have to cycle through each elements of the array/hash and *foreach*, run the dns resolver, which would still do it one at a time. I've been looking into this more, and It think the only why I am going to get his done, is by forking processes, and have each of the child proccesses do (number of children / total number of ip's to resolve) Does anybody know if you can have uhhh *global variables that are shared/seen/changed by the parent and all the children? Thanks! Mike |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Running multiple commands at once |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|