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