Operating System - HP-UX
1834789 Members
2359 Online
110070 Solutions
New Discussion

shell use telnet not work normal....

 
NETSKYCN
Occasional Contributor

shell use telnet not work normal....

Hi,all,

The test.sh is use telnet to connect the HP-UX 11.11u server,but it closed while the username echoed.
But,when user telnet command is normal work.
HOW/WHY it happened? Thanks.
------------------------
test.sh

#!/bin/sh
# test.sh
(
sleep 1
echo "info"
sleep 6
echo "abc123"
sleep 1
echo "vt100"
sleep 2
echo "cd ..;pwd"
sleep 2
echo "exit"
) | telnet 192.168.36.21


--------------------------------
% sh ./test.sh

Trying...
Connected to 192.168.36.21.
Escape character is '^]'.
Local flow control on
Telnet TERMINAL-SPEED option ON
Authorized Access Only.

login: info
Password: Connection closed by foreign host.



NORMAL work.
-----------------------------
telnet 192.168.36.21
Trying...
Connected to 192.1168.36.21.
Escape character is '^]'.
Local flow control on
Telnet TERMINAL-SPEED option ON
Authorized Access Only.

login: info
Password:
Please wait...checking for disk quotas
(c)Copyright 1983-2000 Hewlett-Packard Co., All Rights Reserved.
(........)
Authorized Access Only.
TERM = (hp) vt100
4 REPLIES 4
Peter Godron
Honored Contributor

Re: shell use telnet not work normal....

Dennis Handly
Acclaimed Contributor

Re: shell use telnet not work normal....

Rasheed Tamton
Honored Contributor

Re: shell use telnet not work normal....

Hi,

>sleep 1
>echo "info"
>sleep 6
>echo "abc123"


How about increasing the first sleep to 4 or 5 and after the user name to reduce the sleep value to 1 or 2 - as below:

sleep 5
echo "info"
sleep 1
echo "abc123"

Re: shell use telnet not work normal....

Hi,

For this kind of thing you'd do much better to use expect rather than try and create a shell script for it:

http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.43/

Note all the run time dependencies you also need to install.

HTH

Duncan

I am an HPE Employee
Accept or Kudo