Do not use function prototypes. This turns out to be a bad idea although it looks familiar from other languages. There is reason for them, but this is not it.
Once you have done that, I could move the main loop part of
the code to the front and put the subs at the end.
I recoded one sub for you.
#---------------------------------------------------------------- # Execute a command on a Zhone device - recoded***** #---------------------------------------------------------------- sub zhoneCommand { my ($command,$session) = @_; #<- look at this line for I/F my @output=$session->cmd(String => "$command", Errmode => 'return'); chomp @output; return(@output); } #-------------- I would use fetchall_arrayref for a small, simple result set like this +. You get a reference to an array of server_host's. Then just iterate over that array. #--------------------- # loop through the servers table to pull data for each server my $sql = $dbc->prepare("SELECT server_host FROM servers"); my $result = $sql->execute(); or die "Unable to execute sql: $sql->errstr"; my $host_array_ref = $result->fetchall_arrayref() or die "can't get a +rray ref! $sql->errstr"; foreach my $rowref (@$host_array_ref) { my ($host) = @$rowref; print "Calling telenet stuff for $host\n"; #a little debugging o +utput is fine # call your telenet routine on this host }
In reply to Re: For each loop through mysql db to run Net::Telnet command
by Marshall
in thread For each loop through mysql db to run Net::Telnet command
by jay83
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |