Xshell Forum

Xshell Script does not Auto Login device

Last post: Wednesday, September 25, 2013 2:20 AM by Support, 1 reply

Monday, September 23, 2013 10:36 PM - le tian

Xshell Script does not Auto Login device

My English is not good, briefly describe, I wrote a script that is executed as always pops up the password dialog box, you can not Auto Login device. Script as follows:

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:\SWbackup\list1.txt",Forreading, False)
xsh.Screen.Synchronous = True
DO While file1.AtEndOfStream <> True
line = file1.ReadLine
params = Split (line)
xsh.Session.LogFilePath = "d:\SWbackup\log\" & params(0) & ".txt"
Dim host
host = params(1)
Dim user
user = params(2)
Dim password
password = params(3)
xsh.Session.Open "SSH://" & user & "@" & host
xsh.Screen.Send VbCr
xsh.Session.Sleep 100
xsh.Screen.waitForString "#"
xsh.Session.Sleep 100
str1 = "show config"
xsh.Screen.Send str1 & vbcr
xsh.Screen.waitForString "--- Press CTRL+C to quit ---"
xsh.Screen.Send " " & vbcr
xsh.Screen.waitForString "#"
xsh.Session.Sleep 100
xsh.Screen.Synchronous = False
End Sub

Program Ver. : Xshell 4
Attachment ssh.vbs (1.1 KB)  
Wednesday, September 25, 2013 2:20 AM - Support

Re: Xshell Script does not Auto Login device

It looks like there is an error in our example script file. SSH protocol always opens up a dialog box due to different types of authentication methods that SSH offers.

Try using this script instead:

Sub Main
xsh.Session.Open "ssh://username:password@host"
xsh.Screen.Synchronous = true
End Sub

Please remember this will have your password in the script file.

Technical Support