Xshell Forum

Script Error!!

Last post: Wednesday, August 26, 2015 8:20 AM by Support, 4 reply

 
Saturday, September 28, 2013 7:13 PM - le tian

Script Error!!

 
I encountered a new problem, when I run the following script:

sub main
xsh.screen.waitForStrings ("this",1000)
end sub

Always prompts me:“调用过程(sub)时不能使用括号。”

I do not know how to solve, please help me. Thank you!

Program Ver. : Xshell 4
Monday, September 30, 2013 9:00 AM - Support

Re: Script Error!!

 
Have you tried using it like this?

xsh.Screen.WaitForString "this"
xsh.Session.Sleep 100

Can you tell us what you are trying to achieve with this script?

---
Technical Support
Wednesday, October 2, 2013 6:27 PM - le tian

Re: Script Error!!

 
I want to use this script to grab the device configuration, but the configuration of the device can only split-screen display, so I want to appear when I'm waiting for the string to the next step, when the string does not appear, wait after a few seconds and then moves down.

my scriot :
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 100
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.Screen.Send vbcr & vbcr & vbcr
xsh.Session.Sleep 100
Dim str8
str8 = xsh.Screen.Get(xsh.Screen.CurrentRow,1,xsh.Screen.CurrentRow,1)
xsh.Dialog.Msgbox(str8)
If str8 = "<" Then
xsh.Screen.Send "super" & 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
str1 = "dis cu"
xsh.Screen.Send str1 & vbcr
xsh.Screen.waitForStrings ("---- More ----",100)
xsh.Session.Sleep 1000
xsh.Screen.Send " "
xsh.Screen.waitForString "return"
xsh.Session.StopLog
xsh.Session.Close

Else
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.waitForStrings (" --More-- ",1000)
xsh.Session.Sleep 1000
xsh.Screen.Send " " & VbCr
xsh.Screen.waitForString "#"
xsh.Session.StopLog
xsh.Session.Close
xsh.Session.Sleep 10
End If
loop
xsh.Screen.Synchronous = False
xsh.Dialog.Msgbox("脚本运行完毕!")
End Sub

Wednesday, August 19, 2015 9:33 AM - test

Re: Script Error!!

 
this will not work! ----> xsh.Screen.waitForStrings (" --More-- ",1000)
Wednesday, August 26, 2015 8:20 AM - Support

Re: Script Error!!

 
A fix for waitForStrings function will be included in the next release. It will fix the timeout bug.

---
Technical Support