1833405 Members
2917 Online
110052 Solutions
New Discussion

telnet using script

 
Srikanth Vukkadala
New Member

telnet using script

Hi,

I want to know how to telnet a remote Unix server using a script from Linux server
when I am using a script like this
#!/bin/bash
(echo open 10.101.1.181
sleep 1
echo root
sleep 1
echo passwd )|telnet
then I am getting error "Connection closed by foreign host"

5 REPLIES 5
Arunvijai_4
Honored Contributor

Re: telnet using script

Hi,

You can get more information from these threads,

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

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
RAC_1
Honored Contributor

Re: telnet using script

I would change sleep 1 to sleep 2 and also check if root login is allowed on remote host or not.
There is no substitute to HARDWORK
Bharat Katkar
Honored Contributor

Re: telnet using script

Also have a look at "expect" script that helps you enter username and password.

Additionally you can also explore rsh and ssh option.

See man rsh and man ssh.

Hoope that helps.
Regards,
You need to know a lot to actually know how little you know
Antonio Cardoso_1
Trusted Contributor

Re: telnet using script

Hi,

Expect is a solution,
Another solution is to user Net::Telnet package (look in CPAN at http://search.cpan.org/~jrogers/Net-Telnet-3.03/)

Here attached a simple example that makes use of this Telnet lib to run and printout result of a command after login is performed.

Antonio Cardoso_1
Trusted Contributor

Re: telnet using script

Hi,

Expect is a solution,
Another solution is to use Net::Telnet package (look in CPAN at http://search.cpan.org/~jrogers/Net-Telnet-3.03/)

Here attached a simple example that makes use of this Telnet lib to run and printout result of a command after login is performed.