script [3]

script

Tuesday, December 3, 2013 11:08 PM - taylor

Why WaitForStrings (VARIANT FAR * strArray, long nTimeout) parameter can not be used, will always be an error, the proposed script can reference CRT, crt.Screen.WaitForString "---- More ----", 1. If this feature does not work well, I can only give xshell it.

Program Ver. : Xshell 4


Re: script

Wednesday, December 4, 2013 11:44 PM - Support

Could you send us the script file?


---
Technical Support


Re: script

Wednesday, December 18, 2013 11:19 PM - taylor

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:\test\list1.txt",Forreading, False)
xsh.Screen.Synchronous = True
DO While file1.AtEndOfStream <> True
line = file1.ReadLine
params = Split (line)
xsh.Session.LogFilePath = "d:\test\log\" & params(0) & ".txt"
xsh.Session.StartLog
xsh.Session.Sleep 1000
Dim host
host = params(1)
Dim user
user = params(2)
Dim password
password = params(3)
xsh.Screen.Send vbcr & vbcr & vbcr
xsh.Screen.Synchronous = True
xsh.Session.Open "SSH://" & user & ":" & password & "@" & host
xsh.Screen.Synchronous = True
xsh.Session.Sleep 1000
xsh.Screen.Send vbcr & vbcr & vbcr
xsh.Session.Sleep 1000
Dim le
le = xsh.Screen.Get(xsh.Screen.CurrentRow,1,xsh.Screen.CurrentRow,1)
xsh.Dialog.Msgbox(le)
If le = "<" Then
xsh.Session.Sleep 100
xsh.Screen.Synchronous = True
xsh.Screen.waitForString ">"
xsh.Session.Sleep 100
str2 = " dis ip interface brief"
xsh.Screen.Send str2 & vbcr
xsh.Screen.WaitForString (---- More ----,100)
xsh.Session.Sleep 100
xsh.Screen.Send " " & vbcr
xsh.Session.Sleep 1000
xsh.Screen.Send " "
xsh.Screen.waitForString "#" & vbCrLf & "return"
xsh.Session.StopLog
xsh.Session.Close

Else
xsh.Session.Sleep 100
xsh.Screen.Send "enable" & vbcr
xsh.Screen.waitForString "Password: "
xsh.Screen.Send params(4) & vbcr & vbcr & vbcr & vbcr
xsh.Screen.Synchronous = True
xsh.Screen.waitForString "#"
xsh.Session.Sleep 1000
str01 = "show run"
xsh.Screen.Send str01 & vbcr
xsh.Screen.waitForString (--More-- ,100)
xsh.Session.Sleep 1000
xsh.Screen.Send " " & VbCr
xsh.Screen.waitForString "end" & vbcrlf
xsh.Session.StopLog
xsh.Session.Close
xsh.Session.Sleep 10
End If
loop
xsh.Screen.Synchronous = False
xsh.Dialog.Msgbox("脚本运行完毕!")
End Sub


Re: script

Monday, December 23, 2013 9:42 PM - Support

Our developers have found a problem with waitforstrings function. It has been reported and will be fixed shortly.

---
Technical Support


Previous views: 454