0

How to telnet host port in my script so that i do not have to give login name and password manually.

For example

telnet Host 2000
login:
Password: 

I want to use this in a shell script, how can i avoid user login and password OR How to pass in a single line?

user2663468
  • 85
  • 2
  • 8
  • If the host you connect to requires a username and password, there's not really that much you can do about it. There are tools like [Expect](http://en.wikipedia.org/wiki/Expect) which can help you provide the login details, but you still need to provide them. Another way is to not use Telnet at all, and instead use SSH and have your public key in the target system. – Some programmer dude Jun 04 '15 at 09:46
  • this is to use Command line Manager, SSH wont help. – user2663468 Jun 04 '15 at 09:54

1 Answers1

1

You appear to be talking about IBM Tivoli Netcool/Impact or something like this router product (clarification should have been provided in the question).

The rsh and rlogin programs are designed to work in this manner, using a .rhosts file. While they (including telnet) have been replaced by ssh, they are still usable. Some telnet-oriented products (such as the router) document that they accept either type of connection.

telnet and rlogin are not synonymous - you can read more here: Difference Between Rlogin and Telnet

As noted in comments, the question is about the former (Netcool/Impact), and that it does not accept an rlogin connect. Then (from other comments), you might try using expect. If you have administrative rights (or a cooperative administrator), there are RPMs for expect and its dependencies on Perlz.org:

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105