Operating System - HP-UX
1834814 Members
2599 Online
110070 Solutions
New Discussion

Automatic telnet login and command execution.

 
SOLVED
Go to solution
jayachandran.g
Regular Advisor

Automatic telnet login and command execution.

Hi All

I want to write a script which will make a automatic telnet login to some devices and execute the command without any manual interventions.

rlogin and rsh is not possible i have some boxes which are UNIX embedded devices they don’t have rlogin r rsh features.
6 REPLIES 6
jayachandran.g
Regular Advisor

Re: Automatic telnet login and command execution.

question Part 2


How to achive it how to login and execute the commands help me out in this?
Muthukumar_5
Honored Contributor
Solution

Re: Automatic telnet login and command execution.

You can try as,

(

echo "\n"
sleep 2
echo "\n"
sleep 2
echo "\n"
sleep 2
echo "exit\n"
) | telnet

Change sleep value based on machine speed.

hth.
Easy to suggest when don't know about the problem!
A. Clay Stephenson
Acclaimed Contributor

Re: Automatic telnet login and command execution.

If you must use telnet then by far the easist method is to use Perl with the Net::Telnet module. Net::Telnet is not normally bundled with a Perl distribution can easily download and install it from www.perl.org/CPAN. You get expect like pattern matching, error checking, and timeouts all for free. All of these are difficult at best with traditional scripting approaches.
If it ain't broke, I can fix that.
Camel_1
Valued Contributor

Re: Automatic telnet login and command execution.

try expect, you can download from http://hpux.connect.org.uk/

Simon
jayachandran.g
Regular Advisor

Re: Automatic telnet login and command execution.

Hi

thanks for all of your responces. and i have followed Muthukumars procedure as if it is very simple to follow.

anil_garg5
Occasional Contributor

Re: Automatic telnet login and command execution.

This is good script to use. thanks for sharing Muthukumar.
Muthu,
How can I use stty -echo and stty echo commands within this code as I just want to show only the script output of the remote server and want to hide the other screen messages. Please guide.

Thanks a lot....
Anil