Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am just starting to look at the NET:TELNET module available in perl. I am new to both linux and perl. I have managed to get the modules installed but am having problems getting the output back from commands that i issue. My script file is :
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die'
Prompt=>'/\$ $/i');
$telnet->open('192.168.1.4');
$telnet->login('danny', 'danny');
print $telnet->cmd('ls');
When testing this on my local suse box i get the error :
linux:/home/test-stuff # ./test.pl
syntax error at ./test.pl line 8, near "Prompt"
Execution of ./test.pl aborted due to compilation errors.
linux:/home/test-stuff #
What am i doing wrong ?
Ultimatley my aim is to use NET::TELNET::CISCO module to automate commands to cisco routers. I though id better get the above working first as im new to it !
Thanks, it now seems to let me login however the 'ls' command is not being run. The output i am seeing is :
linux:/home/test-stuff # ./test.pl
eof read waiting for login prompt: Welcome to SuSE Linux 9.2 (i586) - Kernel 2.6.8-24.11-default (3). at ./test.pl line 6
linux:/home/test-stuff #
my current script is :
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>20, Errmode=>'die', Prompt=>'/\$ $/i');
$telnet->open('192.168.1.3');
$telnet->login('root', 'password');
print $telnet->cmd('ls');
$telnet->login('root', 'password') or die("Problem logging in: $!");
Note: I don't know if this will actually work or not as I don't have anything running telnet to check it with and I'm not familiar with the Net::Telnet module, but it should.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.