Operating System - HP-UX
1849290 Members
6166 Online
104042 Solutions
New Discussion

problem to send a command to another host

 
Claudio_4
Occasional Contributor

problem to send a command to another host

Hi all !

I have a problem to execute a remote command from a HP-UX11 box.

BOX1 and BOX2 are both HP-UX11 machines.
From BOX1 i do this command:

( sleep 2
echo root
sleep 2
echo password
sleep 5
echo ls -l
sleep 5
echo exit ) | telnet BOX2

and it work !


I do the same from BOX2 and the result is:

( sleep 2
echo root
sleep 2
echo password
sleep 5
echo ls -l
sleep 5
echo exit ) | telnet BOX1

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

HP-UX saturno B.11.00 E 9000/879 (tb)

login: root
Password: Connection closed by foreign host.

BOX1, can't do this command to itself !
otherwise, if I type:

telnet BOX1
login: root
password: passwod

it works.

Someone can help me ?
thanks
Claudio
4 REPLIES 4
Stefan Schulz
Honored Contributor

Re: problem to send a command to another host

Hi,

your script looks ok. Are you sure there is not typo in the script?

Perhaps there is an extra blank character behind root or the password.

in vi do a :set list to see the end of line. Make sure there are no extra blank characters.

Hope this helps

Regards Stefan
No Mouse found. System halted. Press Mousebutton to continue.
Stefan Farrelly
Honored Contributor

Re: problem to send a command to another host


Scripts look good. If the login or password were wrong you would get a login incorrect message. Connection closed implies the remote server is closing the connection. Possibilities are the account .profile in their homedir, or /etc/profile. Try renaming the .profile in the home dir to something else temporarily and retry, and if it doesnt work check /etc/profile (or the home dirs .kshrc or .shrc files).
Im from Palmerston North, New Zealand, but somehow ended up in London...
Frank Slootweg
Honored Contributor

Re: problem to send a command to another host

As you have found, non-interactive use of telnet(1) is very tricky, especially because there is no handshaking, i.e. you easily get timing issues.

Question: Why are you using telnet(1) instead of remsh(1)?

If you must use telnet(1), you may want to have a look at the 'expect' program. As far as I know, 'expect is available from The HP-UX Porting and Archive Centre http://hpux.connect.org.uk

If you are worried about the limited security that remsh(1) provides, then you may want to have a look at ssh. Hopefully others can give pointers to ssh.
Claudio_4
Occasional Contributor

Re: problem to send a command to another host

Hi all !

Thanks for yours reply.

I'm sure I have no typo in my cmd.

I try to play with /etc/profile and the .profile in user home directory. The /etc/profile are identical in BOX1 and BOX2.
I try to mv the /home/user/.profile from BOX2 to BOX1 but I have the same problem.

I think I'll use remsh to send my remote command.

Thank's to all !
Claudio