[ale] Slightly ot: perl question.

Robert L. Harris Robert.L.Harris at rdlg.net
Mon Feb 14 14:27:58 EST 2005



What happens when you run the select by hand?  I think that while loop should
run as long as you're getting data back from your select. 



Thus spake John Cole (jcole at filink.com):

> Howdy all!
> 
> First of all, it is amazing how much knowledge you gain when you have to fix
> systems you didn't design. :)
> 
> Well, my question for today is why this code snippet doesn't work.  It's in
> a program I'm trying to utilize but I'm not getting the while loop to
> activate.
> 
> # Open a ForkManager handle limiting the number of children
> # to MAX_FORKS
> $pm = new Parallel::ForkManager($scanq);
> 
> #Select scheduled scans to run.
> $sth = $dbh->prepare(qq{
> 	SELECT scan.host, scan.sched_id, sched.sid, sched.timeout,
> sched.username, sched.next_scan
> 	FROM nessus_scan scan, nessus_schedule sched
> 	WHERE scan.status = "S"
> 	AND scan.server_id=$serverid
> 	AND scan.sched_id=sched.id
> 	AND sched.next_scan > 0
> 	} );
> $sth->execute;
> 
> while(($host, $schedid, $sid, $timeout, $username,
> $scantime)=$sth->fetchrow_array){
> 	$pm->start and next; # Do the fork
> 	my $dbhf;
> 
> 	$dbhf =
> DBI->connect("$CONFIG{'DATABASEDSN'}:$CONFIG{'DATABASENAME'}:$CONFIG{'DATABA
> SEHOST'}","$CONFIG{'DATABASEUSER'}","$CONFIG{'DATABASEPASSWORD'}", {
> 		PrintError => 0,
> 		RaiseError => 1,
> 		AutoCommit => 1 } ) or die("Failed to connect :
> $DBI::errstr\n");
> 
> 
> If I do a:
> print $sth->fetchrow_array;
> After the $sth->execute; I get the output from the db as requested.
> 
> I don't see how any of the variables in the while loop are being measured.
> All that exists is a:
> my ($host, $schedid, ...) at the very beginning of this perl script.
> 
> Any ideas anyone?
> 
> Thanks,
> John Cole
> 
> 
> This email and any files transmitted with it are solely intended for the use of the
> addressee(s) and may contain information that is confidential and privileged. If
> you receive this email in error, please advise us by return email immediately.
> Please also disregard the contents of the email, delete it and destroy any copies
> immediately.
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

:wq!
---------------------------------------------------------------------------
Robert L. Harris                     | GPG Key ID: E344DA3B
                                         @ x-hkp://pgp.mit.edu
DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for              First One Should Be A Man
       no-one else.                       - Manowar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature




More information about the Ale mailing list