Operating System - HP-UX
1819744 Members
3013 Online
109606 Solutions
New Discussion юеВ

Re: telnet connection closed by foreign host.

 
SOLVED
Go to solution
Faisal Qureshi
Advisor

telnet connection closed by foreign host.

The following script works fine on HP-UX 11.0:

#!/usr/bin/sh
telnet server1.faq.com 4200 <<-END
login testuser
status
exit
END

But I get the following on Solaris 2.6:

Trying ...
Connected to server1.faq.com.
Escape character is '^]'.
Connection closed by foreign host.

I can manually do:

$ telnet server1.faq.com 4200

and it works fine.

Any suggestions?
Thank you.
15 REPLIES 15
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

Just a guess: try <
I don't know if the - syntax is supported on Solaris or not.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

I checked Sun's BigAdmin site:
http://www.sun.com/bigadmin/
I found in the sh man page for Solaris 7 that the <<- syntax is supported (at least in 7). I still don't know about 2.6.

I did say I was guessing!

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

<
Can there be some setting that is different on Solaris?
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

I assumed you are using either Bourne or Korn shell. Is that right?

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

Bourne shell.
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

What happens when you entering the command and use input redirection from the shell prompt?

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

Please give me an example.
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

Enter exactly what's in your script, only at the shell prompt:

$ telnet server1.faq.com 4200 <<-END
login testuser
status
exit
END

Perhaps you can cut and paste your results for us.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

$ telnet server1.faq.com 4200 <<-END
> login testuser
> status
> exit
> END
Trying 10.5.8.60...
Connected to server1.faq.com.
Escape character is '^]'.
Connection closed by foreign host.
$
Darrell Allen
Honored Contributor

Re: telnet connection closed by foreign host.

Silly question: Is 10.5.8.60 the correct server?

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

Here's what the output looks like on HP-UX 11.0:

$ telnet server1.faq.com 4200 <<-END
> login testuser
> status
> exit
> END
Trying...
Connected to server1.faq.com.
Escape character is '^]'.
<9FB1257C34542A9770302F2997DD9D1E4BA039A9@server1.faq.com>
OK
* 4073 messages queued
* 31 current incoming SMTP associations
* 88 current outgoing SMTP associations
* 0 current cached SMTP associations
* 1 current manager associations
OK
OK Bye
Connection closed by foreign host.
$
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

Yes 10.5.8.60 is correct.
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

I've tried this already with no luck:

$ sleep 5 | telnet server1.faq.com 4200 <<-END
Kenny Chau
Trusted Contributor
Solution

Re: telnet connection closed by foreign host.

Hi,

Maybe you can try this script:

# here 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

I had tested it on my HP-UX and Solaris Server before.

Hope this helps.
Kenny.
Kenny
Faisal Qureshi
Advisor

Re: telnet connection closed by foreign host.

Thank you Kenny. Problem solved!