Thank you all - here is the working code segment:

#################################### //code this below to loop through + all the servers with DB connection, join all results into one array +#################################### my $dsn = "DBI:mysql:table:localhost"; my $username = "username"; my $password = 'password'; 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 server_test"); $sql->execute() or die "Unable to execute sql: $sql->errstr"; my $host_array_ref = $sql->fetchall_arrayref() or die "can't get array + ref! $sql->errstr"; 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 = "user"; my $password = "password"; 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: 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.