If you need anything else, take a look at autoexpect, it does pretty much everything for you! (Ever tried recording in the AppleScript Editor? Ah, the memories…)
Obligatory warning: storing passwords as we’re doing here is BAD. We could improve things SLIGHTLY by feeding the password as a command line parameter, but that is still BAD. I am using this just because the systems to which I auto-log-in are devices in development on my own desktop, on a local network, whose passwords will be changed pre-shipping, and my computer is single-user. You've been warned. You will have deserved whatever happens to you!
Save this in a text file, say autologin.exp; make it executable with chmod u+x autologin.exp; run it as ./autologin.exp 22.214.171.124 .
#!/usr/bin/expect -f set IP [lindex $argv 0] set timeout -1 spawn telnet $IP expect “login: “ send “mylogin\n” expect “\nPassword: “ send “mypassword\n” interact send_user “EXPECT SCRIPT FINISHED\n”