No, you can't do it like this. You would have to use a tool like
expect, but even so, this isn't the best way. Two main alternatives exist:-
- rsh/resh/remsh/rlogin
- ssh
The first set uses plain ASCII text over the network to shake hands with a server that will accept your connection. It must be offering the service of course. You would set up a .rhosts file for the user you are connecting to.
The second is better in many ways and should be preferred if your server offers SSH. You can set up a key-pair and authenticate the client connection request and then usage is much easier and the connection is encrypted (data compression built in if you have lots of output)
What client and server OS and versions are you operating. Do you have any of these services available on the server, or is it really just telnet?
It also depends what you are trying to achieve. is it a true interactive login, or running a command on the server?
Regards,
Robin
Liverpool/Blackburn
UK