I do not have the Term::ReadKey module installed on my system so I removed that. There could be your problem. Or at least I had no problem not using this module and that was the only difference between your code and mine. It would also be a good idea to chomp your variables before using them incase a user enters a whitespace at the end of their user or pass or if a newline sneaks through somehow.#!/usr/bin/perl use Net::Telnet; $telnet = Net::Telnet->new('192.168.1.65'); print "Login Name : "; $HOST = <STDIN>; print "Password : "; $USER = <>; $telnet->login($HOST,$USER) or die print "can't access server"; @ls = $telnet->cmd('ls'); for(@ls){print;}
Edit:
Ok I installed that module to try and give you some better advice but alas mine runs perfectly.
Could it be an issue with the telnet server? Does the second user you are trying actually exist on the system?#!/usr/bin/perl use Net::Telnet; use Term::ReadKey; $telnet = Net::Telnet->new('192.168.1.65'); print "Login Name : "; $HOST = <STDIN>; ReadMode("noecho",STDIN); print "Password : "; $USER = <>; print "\n"; ReadMode("original",STDIN); $telnet->login($HOST,$USER) or die print "can't access server"; @ls = $telnet->cmd('ls'); for(@ls){print;}
In reply to Re: login remotely through telnet
by Elijah
in thread login remotely through telnet
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |