Xshell Forum

Tech Support (company undisclosed)

Last post: Friday, November 27, 2015 6:20 PM by Support, 1 reply

Thursday, November 26, 2015 9:23 PM - Brian

Tech Support (company undisclosed)


I am trying to write a script to use with xShell 4 within my company. What I need it to do is prompt the user for the numeric server number before trying to connect to the server. I can't seem to find a way with vbscript to get that info and then include the variable where it's stored in the ssh command that gets sent to xShell.

Here is the start of my script file:

Sub Main
' Some code here that prompts for the server number and stores it to a variable represented by <NUMBER> further down
xsh.Screen.Synchronous = true
xsh.Screen.Send "ssh root@server<NUMBER>.mycompanysdomain.com"
xsh.Screen.Send VbCr
xsh.Screen.Synchronous = false
End Sub

An example would be I need to connect to server 2101, so I would run this script within xShell, get a prompt to the effect "What is the number of the server you are trying to connect to?: ", I'd enter 2101 and hit enter, then the script would send the following to xShell:
ssh root@server2102.mycompanysdomain.com
and then send the carriage return. My company uses RSA keys for authentication so passwords are not needed.

Thanks for any help.

Program Ver. : Xshell 4
Friday, November 27, 2015 6:20 PM - Support

Re: Tech Support (company undisclosed)

Hi Brian,

You can use the following script:

Sub Main()
xsh.Screen.Synchronous = true
Description = "Enter your host number?"
Title = "Server selection"
DefaultValue = "2012"
IsPassword = FALSE
NUMBER = xsh.dialog.prompt(Description, Title, DefaultValue , IsPassword)
xsh.Screen.Send "ssh root@server"+NUMBER+".mycompanysdomain.com"
xsh.Screen.Send VbCr
xsh.Screen.Synchronous = false
End Sub

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog