Skip to main content

Script Function for Importing Current Session Name

By Monday June 13th, 2016Features

With the latest release of Xmanager Enterprise and Xshell we’ve included a new script function, SessionName, for importing the current session name. This feature was requested by one of our Xshell users in our forums.

Utilization is simple by using the following function:
xsh.Session.SessionName

Let’s look at the actual code:
Sub Main()
xsh.Dialog.Msgbox(xsh.Session.SessionName)
End Sub

The UX team here at NetSarang considered how users can effectively use the newly added SessionName function in combination with existing features. They concluded that you can use SessionName similarly to environment variables, as in you can use it to call variables from outside the script itself. Therefore, SessionName can be used by following the general steps below:

  1. Create a session
  2. Create a script which utilizes environment variables
  3. In Session Properties navigate to Connection -> Login Scripts and check the “Execute script when session starts” box.
  4. Select the script you created above
  5. For the sake of convenience, move the session file you create above from the session folder to an easily accessed path (e.g. Desktop)
  6. Change the script behavior to change the session file name

The following is the default script:
Sub Main()
Dim args
args = "args: " & xsh.Session.SessionName
xsh.Dialog.Msgbox(args)
End Sub

You can also use SessionName as a parameter using the Split function like so: “sameplcommand, param1, param2.xsh”
sessionanmedlg
Sub Main()
Dim msg
For Each args In Split(xsh.Session.SessionName, ",")
msg = msg & "args: " & args & vbCrLf
Next
xsh.Dialog.MsgBox(msg)
End Sub

There also exists a similar script function, TabText. Unlike SessionName, it outputs the name applied to the session’s tab in Xshell. The function is as follows:
xsh.Session.TabText

The applications for these script functions are endless! We hope you can use them to make your Linux experience more enjoyable.

Leave a Reply

16 − 14 =