Need help on Perl telnet Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help on Perl telnet Script
# 1  
Old 09-26-2012
Need help on Perl telnet Script

Hi...

Iam running the following Perl Script for telnet and running the commands.The script is exited without any errors.But the telnet commands are not executed,Please help me to resolve my problem.

My telnet session
Code:
#telnet 9.121.61.2 2013

Trying 9.121.61.2...
Connected to 9.121.61.2.
Escape character is '^]'.

Perl Script
Code:
#!/usr/bin/perl -w 
use Net::Telnet();
$telnet = new Net::Telnet(Timeout =>60,
                          Errmode=>'die',
                          Prompt  => '/[\$#%:>] $/');

$telnet->open('9.121.61.2 2013');
print ("\ntelnet is successful\n");
sleep 2;

$telnet->print("iscli");

$telnet->waitfor('/login: $/i');
$telnet->print("admin") ;
$telnet->waitfor('/password: $/i');
$telnet->print("admin");

sleep 20;
$telnet->print("en");
sleep 1;
$telnet->cmd('config t');
$telnet->cmd('interface port INTA1');
$telnet->cmd('shut');
print ("\nport Shut is successful\n");
sleep 5;

$telnet->close;

Please help to solve the issue.

Last edited by Franklin52; 09-27-2012 at 08:24 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 10-05-2012
Just a quick look: The reference says for open port you need 4 arguments or at least two and a comma?

Net::Telnet - search.cpan.org

open - connect to port on remote host $ok = $obj->open($host); $ok = $obj->open([Host => $host,] [Port => $port,] [Errmode => $mode,] [Timeout => $secs,]);
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl telnet to router run commands from file

I have a perl script that is called with a router name command list file and output file. The command file can be very large, up to 3k of commands. At first I dumped the command list file to an array and ran the entire file on the router and captured the output. It worked ok for a command list in... (1 Reply)
Discussion started by: numele
1 Replies

2. Programming

Perl telnet

Hi all, Im trying to make telnet session to one of my 700 switches and im using the Net::Telnet module and have this error ... "timed-out waiting for login prompt at telnet.pl line 13". that is this line "$t->login($username, $passwd);" but the username and password iv used are not wrong. What... (2 Replies)
Discussion started by: IvanMP
2 Replies

3. Shell Programming and Scripting

Perl Telnet cisco routers

Hi all i have little problem finding solution about simple telnet script .... i have 250 routers and on some i have different password and on some they ask just for password no username. So for example 1,2,3 have username and password (user,password) 4, and 5 have different username and password... (0 Replies)
Discussion started by: IvanMP
0 Replies

4. Shell Programming and Scripting

perl telnet issue with cisco

Hi Experts, I am using perl to telnet on cisco boxes. We have this stupid cisco node which does not support "terminal Length0" command. Since I am using Net::Telnet and capturing output with @output = $telnet->cmd('cmd'); Say @output = $telnet->cmd('show version'); Now problem... (2 Replies)
Discussion started by: mtomar
2 Replies

5. Shell Programming and Scripting

silent telnet and ssh using perl

Hi Experts, I use perl telnet and ssh for normal tasks and health checks. everything works fine but i would like to run scripts silently and print only data as i wish to. by silent i mean.no banners /no prompts/ nothing. I will format data before i print it on screen. just formatted... (3 Replies)
Discussion started by: mtomar
3 Replies

6. Shell Programming and Scripting

Need Help on Telnet using PERL Scripting

Iam trying to connect to a system through Telnet using net::Telnet Module #!/usr/bin/perl -w use net::Telnet $myPassword = "abcdef"; $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die'); $telnet->open (10.10.20.00); $telnet->waitfor ('/USERCODE: $/i'); $telnet->print('abc');... (2 Replies)
Discussion started by: sudhakaryadav
2 Replies

7. AIX

Automation from Windows to Linux - Telnet and su using perl

Here is my requirement to automate the deployment procedure for my project. Telnet to AIX box (say SERVER1) from windows machine (with USER1) Select the server to login say "SERVER2" su as different user say "USER2"(Owner of the deployed files) Execute the script (Script has so many... (1 Reply)
Discussion started by: nurainos
1 Replies

8. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

9. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

10. Shell Programming and Scripting

Perl script for telnet

Is it possible to write a Perl script that will attempt to telnet to multiple servers and login to each one? We have numerous servers and on occasion we are unable to connect. I'd like to be more proactive and have a script that runs every 30 minutes and attempts to login and then will send an... (2 Replies)
Discussion started by: ssmiths001
2 Replies
Login or Register to Ask a Question