PerlMe has asked for the wisdom of the Perl Monks concerning the following question:

I was trying to use Net::Telnet in a perl script. I get can't locate Net/Telnet.pm errors while executing the perl script
#!/usr/bin/perl5 use Net::Telnet (); $username = rami $passwd = rami $t = new Net::Telnet (Timeout => 10,Prompt => '/bash\$ $/'); $t->open("10.10.4.11"); #$t->login($username, $passwd); @lines = $t->cmd("ls"); print @lines;
I get the following message while executing the script Can't locate Net/Telnet.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at telnettest.pl line 2. BEGIN failed--compilation aborted at telnettest.pl line 2

Replies are listed 'Best First'.
Re: Telnet: Can't locate Net/Telnet.pm
by marto (Cardinal) on Jul 16, 2007 at 21:33 UTC
    Hi PerlMe,

    Did you install Net::Telnet properly? Take a look at Installing Modules from the Tutorials section of this site should you need help installing modules.

    Update: I suspect this may be a typo but
    $username = rami $passwd = rami

    Should of look something like:
    use strict; use warnings; my $username = 'rami'; my $passwd = 'rami'; etc...
    Adding use strict; and use warnings; is a good idea when you are developing/debugging code.

    Hope this helps

    Martin
      Thanks Martin, I finally got the installation right. I was using unix based OS, 'ubuntu' and 'Fedora'. I use the following commands to install it. #perl -MCPAN -e'shell' Cpan> install Net::Telnet