第一步:
# $language = "VBScript"
# $interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso,file1,line,str1,params
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fso.OpenTextFile("d:\李贺.txt",Forreading, False)
crt.Screen.Synchronous = True
DO While file1.AtEndOfStream <> True
line = file1.ReadLine
crt.Session.Connect "/TELNET " & params(0)
crt.Screen.WaitForString "Username:"
crt.Screen.Send "lihe" & VbCr
crt.Screen.WaitForString "Password:"
crt.Screen.Send "lihe" & VbCr
crt.Screen.Send params(1) & vbcr
crt.Screen.Send "enable" & vbcr
crt.Screen.WaitForString "Password:"
crt.Screen.Send params(2) & vbcr
crt.Screen.waitForString "#"
str1 = "copy startup t"
str1 = str1 & "backup(" & params(0) &")"
& ".cfg"
crt.Screen.Send str1 & vbcr
crt.Screen.WaitForString "]?"
crt.Screen.Send vbcr
crt.Screen.WaitForString "]?"
crt.Screen.Send vbcr
crt.Screen.waitForString "#",3
crt.Session.Disconnect
loop
crt.Screen.Synchronous = False
End Sub
李贺.txt文本文件为事先编辑好的
格式如:
192.168.1.1
192.168.1.254
第二步
应用脚本:
* 打开CRT软件
* 点击“Script"菜单
* 点击“RUN”
* 在弹出菜单中找到刚才编写的脚本存放的目录,并输入脚本的名字crt.vbs.
这时可以看到脚本在执行,如下:
User Access Verification
Username:lihe
Password:lihe
Router#
文章转载至