Just create a script file with the commands you would type. Example:
open [ip]
USER username
PASS password
bye
Note: it's better to have the program to log into IP from a internal command, not by "TELNET [IP]", if possible.
After creating such script, do:
TELNET < SCRIPT.TXT
-- or, to supress the output --
TELNET < SCRIPT.TXT > NUL
Now, in order to do that via batch file, just create the script via batch file, like this (I'll use as example the same script I created above):
@echo off
echo open [ip]> %temp%.\script.dat
echo USER username>> %temp%.\script.dat
echo PASS password>> %temp%.\script.dat
echo bye>> %temp%.\script.dat
TELNET < %TEMP%.\SCRIPT.DAT > NUL
del %temp%.\script.dat
Got it? Some programs (such as FTP.EXE) will ask username and password by default, and you need to include a switch when calling it so it won't do that (it will 'wait' for you give the USER and PASS commands)
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br