Thank you - I made edits to the main loop but the error in the terminal is : Can't locate object method "fetchall_arrayref" via package "2" (perhaps you forgot to load "2"?) at filepath line XXXXXXXXXX
my $dbc = DBI->connect($dsn, $username, $password) or die "Unable to c +onnect to mysql: $DBI::errstr\n"; #//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"; XXXX ERROR LINE XXXXX my $host_array_ref = $result->fetchall_arrayref( +) or die "can't get array ref! $sql->errstr"; XXXXXXXXXX foreach my $rowref (@$host_array_ref) { my ($host) = @$rowref; print "Calling telenet stuff for $host\n"; #a little debugging ou +tput is fine # call your telnet routine on this host my $device = $host; my $user = "admin"; my $password = "zhone"; STDOUT->autoflush; die "Unable to telnet to device\n" if (! (my $session=zhoneConnect($de +vice))); die "unable to login to device\n" if (! zhoneLogin($session, $user, $p +assword)); zhoneCommand($session, "timeout off"); zhoneCommand($session, "setline 0"); $session->prompt('/\n\rAUTO>\s*/'); zhoneCommand($session, "setprompt session AUTO>\r"); my @output=zhoneCommand($session, "bridge show"); for (@output) { print "$_\n"; } zhoneDisconnect($session); }
In reply to Re^2: For each loop through mysql db to run Net::Telnet command
by jay83
in thread For each loop through mysql db to run Net::Telnet command
by jay83
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |