Perl script for telnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script for telnet
# 1  
Old 05-15-2006
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 email if it can't.
# 2  
Old 05-15-2006
If you just want to check whether the telnet port is reachable you don't quite need to do the real telnet login, right? You may probably just try to set up a connection to the telnet port on that machine with the connect() function, then the return value will tell you whether a TCP connection can be established. This also minimizes the security risk of password eavesdropping.

If you really want to verify a real login, then perhaps

http://search.cpan.org/~jrogers/Net-.../Net/Telnet.pm

will help (I haven't used it before).
# 3  
Old 05-20-2006
Try a bash script instead!

#!/bin/bash

export USERNAME=xxxxx
export PDW=xxxxxxxx

cat hosts.txt | while read H
do
( echo open $H
sleep 1
echo $USERNAME
sleep 1
echo $PDW
sleep 1
/somedir/some_script.sh 2>&1 > /dev/null
echo exit ) | telnet
done
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

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 #telnet 9.121.61.2 2013 Trying 9.121.61.2... Connected to... (1 Reply)
Discussion started by: raja_blr
1 Replies

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question