On 7/8/11 Fri Jul 8, 2011 5:59 AM, "Irfan Sayed" <irfan_sayed2...@yahoo.com> scribbled:
> hi, > > i am using Net::Telnet module to connect to remote hosts > i able to to successfully connect to remote host and run the "ls" command > but the issue is , the output of command is not getting printed to scalar > variable > > > use Net::Telnet (); > $t = new Net::Telnet (Timeout => 10, > Prompt => '/bash\$ $/'); > $t->open("abc"); > $t->login($username, $passwd); > @lines = $t->cmd("ls"); > print @lines; That looks like the sample code included with 'perldoc Net::Telnet'. That presumes that you have assigned valid values to the $username and $passwd variables. Have you? You have no error checking in your code. Since you are apparently getting an error, it is time to add some error checking. See 'perldoc Net::Telnet' for how to do this. The documentation recommends the use of input_log() and dump_log() to trace the data sent back and forth between your program and the telnet server. Unfortunately, I cannot find a telnet server to test your program. Most telnet access has been replaced by ssh these days. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/