Problem: Automate telnet commands from DOS

Problem: Automate telnet commands from DOS

I have a current need for a way to automate login and commands to fiber switches (Brocade, McData) from a DOS batch file, and save the output to a text file.  I cannot install an application, as this will be run on different windows machines everytime (new sites).  So I need a stand alone utility.

I found this thread that lead me to a great utility:

http://www.experts-exchange.com/Hardware/Routers/Q_21108412.html

Telnet Scripting Tool (TST10) by Albert Yale is exactly what I needed.

Unfortunately the homepage and email address no longer exist, but here is a good place to download it:

http://users.skynet.be/bk330420/gg/albert.html

It works excellent on the DS32B Brocade switches, but I’m having a problem when running it against the DS16B switches.

The basic idea with TST10 is you create a text file with WAIT/SEND commands (I use the batch file to dynamically write this file), and run TST10.exe against it.  It will look for the pattern you define with WAIT, and respond with your SEND commands.  The problem I am having is for some reason this particular model hangs after the first SEND command.

I am sending this against a Brocade switch:

1.2.3.4 23
WAIT “login:”
SEND “administrator\m”
WAIT “Password:”
SEND “mypassword\m”
WAIT “>”
SEND “my commands”

TST10.exe uses “\m” to send a carriage return.  These exact commands work wonderfully on a DS32B.  When running it against a DS16B, it hangs after sending my username.  On the console that pops up (you can interact with it while the script runs,) I can see that a carriage return is indeed entered after it sends “administrator”, but the switch does not seem to accept it.  The cursor moves down a line, but the “password:” prompt does not appear (my second WAIT definition).  In fact, if I specify multiple “\m”, the cursor will move down that many lines, but I will not see the “password:” prompt.  After some troubleshooting, it seems this particular Brocade model is looking for “control+enter”.  If I enter this key combination manually, I will then see the “password:” prompt and the script will continue on.  If I telnet manually into the switch, all that is needed is “enter”, and not “control+enter”.

Does anybody know how I would send a “control+enter” through this application?  I have tried “^\m” “\^\m” but it simply prints those characters before the carriage return.

Or, does anybody know of another windows based scriptable utility that can be run standalone and not be installed?


Solution: Automate telnet commands from DOS

This version gets rid of the noise from the batch file:

@echo off

if exist CtlEnt.txt del CtlEnt.txt >NUL

echo e 100 a>_temp.txt
echo r cx>>_temp.txt
echo 1 >>_temp.txt
echo n CtlEnt.txt>>_temp.txt
echo w>>_temp.txt
echo q>>_temp.txt

type _temp.txt|debug>NUL

echo 1.2.3.4 23>script.txt
echo WAIT “login:”>>script.txt
echo SEND “administrator”>>script.txt
copy /b script.txt+CtlEnt.txt script.txt>NUL
echo WAIT “Password:”>>script.txt
echo SEND “mypassword”>>script.txt
copy /b script.txt+CtlEnt.txt script.txt>NUL
echo WAIT “>”>>script.txt
echo SEND “my commands”>>script.txt

del _temp.txt>NUL
del CtlEnt.txt>NUL
echo script.txt contains script