Board logo

标题: 如何实现用批处理输入特定字符并回车执行 [打印本页]

作者: jasonwang     时间: 2009-2-18 00:22    标题: 如何实现用批处理输入特定字符并回车执行

我现在有这样一个需求,如何来实现: 1. 用PING命令,PING IP,如果目标设备存在 2. 输入TELNET IP 3. 出现USER提示后:输入帐号 4. 出现PASSWORD后: 输入密码 5. 出现#号提示符后: 输入REBOOT 6. 循环第1步,直到IP地址为254为止

作者: scriptor     时间: 2009-2-19 00:52
Originally posted by jasonwang at 2009-2-18 00:22: 我现在有这样一个需求,如何来实现: 1. 用PING命令,PING IP,如果目标设备存在 2. 输入TELNET IP 3. 出现USER提示后:输入帐号 4. 出现PASSWORD后: 输入 ...
@echo off rem AutoTlnt.bat rem Auto Detect and Telnet the remote machines, then reboot them rem Version 1.0.0.0 rem Copyright 2009-2010 Scriptor (Scriptor@www.cn-dos.net) rem Created at 23:28 2009年2月18日 rem ============================================================ rem Before you can go on, please read this REM carefully. rem ~ stand for ENTER; rem Modify the IP address you wana test; rem Modify the Username and password to connect the remote machine. rem NOTE: No Permission for Abusing of this script. rem ============================================================ for /l %%a in (1,1,254) do ( ping -n 2 192.168.1.%%a|find /i "ttl" ( echo set sh=WScript.CreateObject("WScript.Shell") >tlnt%%a.vbs echo WScript.Sleep 300 >>tlnt%%a.vbs echo sh.SendKeys "open 192.168.1.%%a ~" >>tlnt%%a.vbs echo WScript.Sleep 500 >>tlnt%%a.vbs echo sh.SendKeys "Username ~" >>tlnt%%a.vbs echo WScript.Sleep 400 >>tlnt%%a.vbs echo sh.SendKeys "Password ~">>tlnt%%a.vbs echo WScript.Sleep 500 >>tlnt%%a.vbs echo sh.SendKeys "reboot ~">>tlnt%%a.vbs start telnet cscript //nologo tlnt%%a.vbs del tlnt%%a.vbs ) )