Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Net::telnet question for prompt only "$" and telnet session has menu

by spivey49 (Monk)
on Aug 31, 2008 at 18:12 UTC ( #708055=note: print w/replies, xml ) Need Help??


in reply to Re^2: Net::telnet question for prompt only "$" and telnet session has menu
in thread Net::telnet question for prompt only "$" and telnet session has menu

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://708055]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2019-12-14 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?