If you have a fast and reliable connection (that is, both computers are in the same LAN), you could use this:
Code:
cat input_file.txt | netcat your_host 23
The contents of input_file.txt is:
Code:
username
password
command1
command2
command3
exit
Looking at the code after a few years I am surprised that it still works. I used the first line (cat input...) in another script to check if a wireless router had still an RF connection. If not, I would reset it. There is a REQUIREMENT that the host you are telnetting to is there and responding. The script I am talking about which did the checking and contains the line (cat input...) I called with cron every 15 minutes. Standard rule: if intervals are below 2 minutes, use a loop and sleep, over 2 minutes, use crontab.
If your connection is not reliable or the host is not always there, use Expect. Tricky to learn Tcl/Expect, but there are plenty of examples around.
jlinkels