我通过GNS3建立了一个小型3路由器网络。我可以通过我的电脑(telnet)连接它并执行简单的cisco命令,如show int brief。 现在我在这里找到了一个批处理文件,我修改了一点来登录所有3个路由器并执行show ip int brief命令。我的屏幕上有所有信息,但我想将它放在.csv文件中。
我更改了路由器IP R1:1.1.1.1,R2:2.2.2.2,R3:3.3.3.3
这是批处理文件
:: Open a Telnet window
start telnet.exe 1.1.1.1
:: Run the script
cscript showipintbrief.vbs
这是vbs文件(showipintbrief.vbs):
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
OBJECT.SendKeys "loginR1password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR1password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
Echo Interface, IP-Address > showipintbrief.csv
OBJECT.SendKeys "telnet 2.2.2.2{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "loginR2password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR2password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "telnet 3.3.3.3{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "loginR3password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR3password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
例如,接口,IP地址,状态和协议应发送到.csv文件
任何人都可以帮忙吗? 非常感谢
答案 0 :(得分:0)
尝试此操作来记录数据并从cmd提示符执行它,其中batchfile.bat是您的批处理文件名。
batchfile.bat >file.log