Scripting telnet commands..

Don
Joined
21 Oct 2002
Posts
46,827
Location
Parts Unknown
Anyone got a nice way to script telnet commands, either through a 3rd party program or using a bat file.

Currently, I've got it going through a VBS using this method


create a batch to connect to telnet and run a script to issue commands ? source

Batch File (named Script.bat ):
:: Open a Telnet window
start telnet.exe 192.168.1.1
:: Run the script
cscript SendKeys.vbs
Command File (named SendKeys.vbs ):

set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
OBJECT.SendKeys "mylogin{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "mypassword{ENTER}"
WScript.sleep 50
OBJECT.SendKeys " cd /var/tmp{ENTER}"
WScript.sleep 50
OBJECT.SendKeys " rm log_web_activity{ENTER}"
WScript.sleep 50
OBJECT.SendKeys " ln -s /dev/null log_web_activity{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "


But if you click anywhere else, the command runs on the open window, not on the CMD prompt. Quite a problem when I'm running this on ~50 telnet clients.

It runs flawlessly if I leave the mouse alone, but it would be nice to have it foolproof

Thanks
 
Back
Top Bottom