cancel
Showing results for 
Search instead for 
Did you mean: 

Automated Telnet on HPUX

SOLVED
Go to solution
Sathish C
Frequent Advisor

Automated Telnet on HPUX

Is it possible to have automated telnet session on HP-UX or any OS for that matter .
Some cause happiness wherever they go; others, whenever they go
6 REPLIES
Franky_1
Respected Contributor
Solution

Re: Automated Telnet on HPUX

Hi Satish,

yes it is

# hostname is the name of the remote machine
# username is the name of the user
# password is the password of the user username

REMOTE=hostname #or IP address
(sleep 5
echo username
sleep 5
echo password
sleep 15
echo "ls -ald /tmp" #Your command
sleep 5
echo exit) |telnet $REMOTE

Regards

Franky
Don't worry be happy
Jean-Luc Oudart
Honored Contributor

Re: Automated Telnet on HPUX

Hi,

You do not specify where from you want to telnet HPUX.
From a PC, you can find some scripting facilities with the terminal emulation software. We have for Reflection for Unix (you can record a session and then edit hte script). I believe this available with other sw.

From Unix, you may use "expect".
Never used it myself, there a few threads in the forum on Expect.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=500029

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=523669

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=590954


Regards,
Jean-Luc
fiat lux
Yogeeraj_1
Honored Contributor

Re: Automated Telnet on HPUX

hi,

you should use expect as a script language for this kind of interaction:

expect can be downloaded from software.hp.com

expect comes from :

http://expect.nist.gov/

You may use a script like:
==================================
#!/bin/sh
# exec expect "$0" ${1+"$@"}
set host [lindex $argv 0]
set login [lindex $argv 1]
set password [lindex $argv 2]
spawn telnet $host
expect "Username:"
send "$login\r"
expect "Password:"
send "$password\r"
interact
==================================

hope this helps!
regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor

Re: Automated Telnet on HPUX

hi again,

Perl solutions are also possible.

Your script would look something like:

===================================
use Net::Telnet ();
$telnet = new Net::Telnet;

$telnet->input_log($LOG);
$telnet->open(Host => $host, Port => $port);
# $telnet->timeout(60);
$telnet->waitfor(String => '>');
$telnet->print($user);
.....
=========================================


hope this helps too!
regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Sathish C
Frequent Advisor

Re: Automated Telnet on HPUX

Yogee ,
Please explain me little bit more your perl script ( am not a perl man ) .for exapmle there is no specification of passwd there . it looks like you are using a class .
Some cause happiness wherever they go; others, whenever they go
Yogeeraj_1
Honored Contributor

Re: Automated Telnet on HPUX

hi again,

this is another piece of example from the docs:
=================================
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die'
Prompt => '/\$ $/i');
$telnet->open('yd.server.mu');
$telnet->login('ydyd', 'bindaas');
print $telnet->cmd('who');

=================================

see also:
http://www.perlfect.com/articles/telnet.shtml

hope this helps!
regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)