From within a Windows 2003\XP batch (.bat). file I need to connect to a system using telnet then pass some commands. I am trying to pipe the commands to a telnet session but am stuck (see code snippet).
I could be miles away from getting this to work or very close.
I cannot use vbscript or third party tools to do this. It must all run from a batch file with no dependencies (other than being able to run telnet).
Can you please provide a code snippet to show how to pass commands to a telnet session?
set DATA=This is a test.
:: Create Session Command File
echo helo %DOMAIN%
echo mail from: %EMAIL_FROM%
echo RCPT TO: %EMAIL_TO%
) > %EMAIL_CMD_FILE%
set /p SESSION="" < %EMAIL_CMD_FILE%
echo %SESSION% | telnet %SMTP_IP% %PORT%