If that's your entire code you're missing a couple of things like the open() and login() methods.

Not sure the purpose of the serverid hash with a single key\value, but here's what the code should be with a hash:

use strict; use warnings; use Net::Telnet; my ($username, $password)=("benlaw", "usertesting"); my $serverid{'testsvr1'} = '10.159.32.21'; my $t = new Net::Telnet (Timeout => 10, Dump_Log=> "err_dump.log", Output_log=> "err_out.log", Prompt => "/\$\s/" ); my @date; while ( my ($key,$value) = each(%servid){ $t->open($key=>$value); $t->login($username,$password); @date = $t->cmd("date"); print @date; $t->close; }

Here's the way I would write it if I had a single server to log into:

use strict; use warnings; use Net::Telnet; my ($username, $password)=("benlaw", "usertesting"); my $serverid = "10.159.32.21"; my $t, @date; $t = new Net::Telnet (Timeout => 10, Dump_Log=> "err_dump.log", Output_log=> "err_out.log", Prompt => "/\$\s/" ); $t->open($serverid); $t->login($username, $password); @date = $t->cmd("date"); print @date; $t->close;


In reply to Re^3: Net::telnet question for prompt only "$" and telnet session has menu by spivey49
in thread Net::telnet question for prompt only "$" and telnet session has menu by benlaw

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.