VBS multisession [1]
VBS multisession
Friday, September 1, 2017 12:54 PM - Toto
Hi all,
I'm trying to open multiple session from a text file and execute some commands (from another text file) in the sessions.
The problem is that it works for the first session but not for the others, and I don't understand why.
Below is a simplified VBS code (which doesn't work either) to give you an idea:
Sub Main
' *** Open, Close, Sleep ***
login = "admin"
pwd = "****"
url = "ssh://" & login & ":" & pwd & "@"
ip_add = "C:\Users\****\Documents\NetSarang\Xshell\Scripts\ScriptSample\Session\IP_add.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(ip_add)
Do Until f.AtEndOfStream
line = f.ReadLine
xsh.Session.Open(url & line & vbCr)
xsh.Screen.Synchronous = true
xsh.Session.Sleep(1000)
'*** StartLog, StopLog ***
log_path = "C:\Users\****\Documents\NetSarang\Xshell\Logs\" & line & ".log"
xsh.Session.LogFilePath = log_path
xsh.Session.StartLog()
xsh.Screen.Send chr(25)
xsh.Screen.Send vbCr
xsh.Screen.Send "show boot"
xsh.Screen.Send vbCr
xsh.Session.Sleep(60000)
xsh.Session.StopLog()
xsh.Session.Close()
Loop
f.Close
End Sub
This works fine for the firt IP in IP_add.txt, but for the others, I just have a message saying :
"Connecting to *the_IP*".
"Connection established"
"To escape to local shell, press 'CTRL+Alt+]''
Nothing appears on the screen and nothing in the log file (but they are created).
Any help is appreciated.
Regards,
Program Ver. : Xshell 5
I'm trying to open multiple session from a text file and execute some commands (from another text file) in the sessions.
The problem is that it works for the first session but not for the others, and I don't understand why.
Below is a simplified VBS code (which doesn't work either) to give you an idea:
Sub Main
' *** Open, Close, Sleep ***
login = "admin"
pwd = "****"
url = "ssh://" & login & ":" & pwd & "@"
ip_add = "C:\Users\****\Documents\NetSarang\Xshell\Scripts\ScriptSample\Session\IP_add.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(ip_add)
Do Until f.AtEndOfStream
line = f.ReadLine
xsh.Session.Open(url & line & vbCr)
xsh.Screen.Synchronous = true
xsh.Session.Sleep(1000)
'*** StartLog, StopLog ***
log_path = "C:\Users\****\Documents\NetSarang\Xshell\Logs\" & line & ".log"
xsh.Session.LogFilePath = log_path
xsh.Session.StartLog()
xsh.Screen.Send chr(25)
xsh.Screen.Send vbCr
xsh.Screen.Send "show boot"
xsh.Screen.Send vbCr
xsh.Session.Sleep(60000)
xsh.Session.StopLog()
xsh.Session.Close()
Loop
f.Close
End Sub
This works fine for the firt IP in IP_add.txt, but for the others, I just have a message saying :
"Connecting to *the_IP*".
"Connection established"
"To escape to local shell, press 'CTRL+Alt+]''
Nothing appears on the screen and nothing in the log file (but they are created).
Any help is appreciated.
Regards,
Program Ver. : Xshell 5
Re: VBS multisession
Monday, September 11, 2017 4:53 PM - Support
Thank you for your patience while we investigated this issue.
Reviewing your script, we've concluded that sleep time is required after xsh.Session.Close().
....
xsh.Session.Sleep(60000)
xsh.Session.StopLog()
xsh.Session.Close()
xsh.Session.Sleep(3000)
...
Technical Support
Like us on Facebook
Follow us on Twitter
Visit our blog Blog
Reviewing your script, we've concluded that sleep time is required after xsh.Session.Close().
....
xsh.Session.Sleep(60000)
xsh.Session.StopLog()
xsh.Session.Close()
xsh.Session.Sleep(3000)
...
Technical Support
Like us on Facebook
Follow us on Twitter
Visit our blog Blog
Previous views: 102