I have to telnet to a lot of hosts and was able to use the below script for automating a single telnet. How can I combine this with a loop of sorts to read through a list of hostnames and open a telnet to each host?
The "catch" is that I have to telnet to two boxes before I can telnet out to the "world". This client has a DMZ server of sorts, then their server, then the remote site machines.
----------------------
@ECHO OFF
:: :::::::::::::::::::::::::::::::::::::::::::::
:: temp_SendKeys.VBS will contain the "commands"
ECHO.set handler=WScript.CreateObject("WScript.Shell")>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To DMZ
ECHO.handler.SendKeys "open 1.2.3.4~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send My Login Name
ECHO.handler.SendKeys "user01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: Send My Password
ECHO.handler.SendKeys "mypass~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send Stuff to be done
ECHO.handler.SendKeys "uname -a~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To Customer server
ECHO.handler.SendKeys "tn dmzsrv01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send My Login Name
ECHO.handler.SendKeys "user01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: Send My Password
ECHO.handler.SendKeys "mypass~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send Stuff to be done
ECHO.handler.SendKeys "uname -a~" >>temp_SendKeys.VBS
ECHO.handler.SendKeys "export TMOUT=0~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To REMOTE Customer site
ECHO.handler.SendKeys "tn exthost01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Logout
:: ECHO.handler.SendKeys "exit~" >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: ECHO.handler.SendKeys " " >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: ECHO.handler.SendKeys "quit~" >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: Open a Telnet Windows
start telnet.EXE
:: Run the script
cscript//nologo temp_SendKeys.VBS
:: Delete the temporary file
DEL temp_SendKeys.VBS
quit
exit
The "catch" is that I have to telnet to two boxes before I can telnet out to the "world". This client has a DMZ server of sorts, then their server, then the remote site machines.
----------------------
@ECHO OFF
:: :::::::::::::::::::::::::::::::::::::::::::::
:: temp_SendKeys.VBS will contain the "commands"
ECHO.set handler=WScript.CreateObject("WScript.Shell")>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To DMZ
ECHO.handler.SendKeys "open 1.2.3.4~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send My Login Name
ECHO.handler.SendKeys "user01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: Send My Password
ECHO.handler.SendKeys "mypass~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send Stuff to be done
ECHO.handler.SendKeys "uname -a~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To Customer server
ECHO.handler.SendKeys "tn dmzsrv01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send My Login Name
ECHO.handler.SendKeys "user01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: Send My Password
ECHO.handler.SendKeys "mypass~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Send Stuff to be done
ECHO.handler.SendKeys "uname -a~" >>temp_SendKeys.VBS
ECHO.handler.SendKeys "export TMOUT=0~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Open Connection To REMOTE Customer site
ECHO.handler.SendKeys "tn exthost01~" >>temp_SendKeys.VBS
ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS
:: :::::::::::::::::::::::::::::::::::::::::::::
:: Logout
:: ECHO.handler.SendKeys "exit~" >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: ECHO.handler.SendKeys " " >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: ECHO.handler.SendKeys "quit~" >>temp_SendKeys.VBS
:: ECHO.WScript.sleep 1250 >>temp_SendKeys.VBS
:: Open a Telnet Windows
start telnet.EXE
:: Run the script
cscript//nologo temp_SendKeys.VBS
:: Delete the temporary file
DEL temp_SendKeys.VBS
quit
exit