#$language = "VBScript"
#$interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const passwd = "xxx_2017"
Dim fso,file1,line,str1,params
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fspenTextFile("c:\xxx\config.txt",Forreading, False)
crt.Screen.Synchronous = False
DO While file1.AtEndOfStream <> True
'read every line
line = file1.ReadLine
crt.Screen.Send line & vbcr
'ip,passwd,en passwd
params = Split (line)
crt.Screen.Send params(0) & vbcr
' 'ssh
crt.Screen.Send "ssh " & params(0) & vbcr
'passwd
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbcr
'en
crt.Screen.WaitForString "v>"
crt.Screen.Send "enable" & vbcr
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbcr
crt.Screen.waitForString "#"
'commands
cmd1 = "sh ip int bri"
cmd2 = "show track"
'str1 = str1 & "backup(" & params(0) &")" & ".cfg"
crt.Screen.Send cmd1 & vbcr
crt.Screen.WaitForString "#"
crt.Screen.Send cmd2 & vbcr
crt.Screen.Send "exit " & vbcr
Loop
'crt.Screen.Synchronous = False
End Sub
the script can only execute for the 1st loop.
it will never read the 2nd line of the file and do ssh to the router?
but if I ' from the 19th line, then it's okay to have the content of the file to be printed on the screen.
Why?
Thanks a lot.
#$interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const passwd = "xxx_2017"
Dim fso,file1,line,str1,params
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fspenTextFile("c:\xxx\config.txt",Forreading, False)
crt.Screen.Synchronous = False
DO While file1.AtEndOfStream <> True
'read every line
line = file1.ReadLine
crt.Screen.Send line & vbcr
'ip,passwd,en passwd
params = Split (line)
crt.Screen.Send params(0) & vbcr
' 'ssh
crt.Screen.Send "ssh " & params(0) & vbcr
'passwd
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbcr
'en
crt.Screen.WaitForString "v>"
crt.Screen.Send "enable" & vbcr
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbcr
crt.Screen.waitForString "#"
'commands
cmd1 = "sh ip int bri"
cmd2 = "show track"
'str1 = str1 & "backup(" & params(0) &")" & ".cfg"
crt.Screen.Send cmd1 & vbcr
crt.Screen.WaitForString "#"
crt.Screen.Send cmd2 & vbcr
crt.Screen.Send "exit " & vbcr
Loop
'crt.Screen.Synchronous = False
End Sub
the script can only execute for the 1st loop.
it will never read the 2nd line of the file and do ssh to the router?
but if I ' from the 19th line, then it's okay to have the content of the file to be printed on the screen.
Why?
Thanks a lot.