• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3537
  • Last Modified:

Telnet From a Batch File


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?


@echo off
set EMAIL_CMD_FILE=c:\temp\mailsend.txt
set SMTP_IP=
set PORT=25
set DOMAIN=mycompany.net
set EMAIL_FROM=me@mycompany.com
set EMAIL_TO=joe@mycompany.com
set DATA=This is a test.
:: Create Session Command File
echo helo %DOMAIN%
echo mail from: %EMAIL_FROM%
echo DATA
echo %DATA%
echo .
echo quit
echo %SESSION%
echo %SESSION% | telnet %SMTP_IP% %PORT%

Open in new window

1 Solution
Adam LeinssCommented:
You know that telnet is unencrypted, right?  And by telneting to a server or workstation over the Internet via telnet would send your password in cleartext?
If you are VPNing in, just copy the batch file to \\targetcomputer\c$\somedir, then telnet in and run the batch file.
Is it absolutely necessary you use a batch file? I've been using Febooti Command Line Email 2.0 under XP (they are up to 3.1 now, so I can't say if things have changed) as part of a script to send off an email for the past 2 years, and it has never forced me to register. There is a Febooti tagline at the bottom of the emails that are sent, but if that isn't bothersome to you, I'd check it out.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now