1
我的代码设置为telnet到交换机,并将启动配置tftp到服务器。如果我将IP地址硬编码到脚本中,此代码完美。在预先写好的代码中循环IP地址替换
我想要做的是将一个IP地址列表(一个接一个地)传递给脚本,以便我可以复制网络上的所有交换机配置。我在下面包含了一些代码,这是我用来创建脚本的代码。我希望能够做的就是用IP地址列表替换“telnet xx.xx.xx.xx”xx.xx.xx.xx条目。
在此先感谢!
这里是代码的副本我使用:
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet xx.xx.xx.xx"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 2 - Issue Commands with pauses'
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "5"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit