in reply to Re: For each loop through mysql db to run Net::Telnet command
in thread For each loop through mysql db to run Net::Telnet command
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: For each loop through mysql db to run Net::Telnet command
by 1nickt (Canon) on Nov 08, 2022 at 20:14 UTC | |
by jay83 (Novice) on Nov 14, 2022 at 13:13 UTC | |
|
Re^3: For each loop through mysql db to run Net::Telnet command
by Marshall (Canon) on Nov 10, 2022 at 15:36 UTC | |
by jay83 (Novice) on Nov 14, 2022 at 13:15 UTC |