SUPPORT > TIPS
Send us a question or comment

 

Send us your tip idea

Login Script to Log in to Multiple Sessions with SecureCRT®

A developer at a telcommunications firm submitted this scripting tip, which allows him to easily change passwords on the dozens of sessions he has to manage. This script can be used with both SecureCRT and CRT™.

"Corporate security requires passwords to change every month...I use a single VBScript login script for all these sessions and then I only change one script every time I have to change the (common) password. I even have the script customize itself, depending on which host is using it, once the login sequence is done."

The script below logs in with the information that is common to all the servers. The script then reads the screen to get the name of the machine to which it's connected. That machine name is then used to decide on additional setup that can be automated before the script terminates and the Telnet session goes interactive.

Here is a link to VBScript login script: MultiSessionLogin_vbs.txt

To learn more about scripting for SecureCRT, visit our Scripting Examples web page.

'~~~~~~~~~~~~~~~~~~~~ Begin MultiSessionLogin.vbs ~~~~~~~~~~~~~~~~~~~~~~~~~~

#$language = "VBScript"
#$interface = "1.0"

' script for logging in to multiple servers

Sub main

' turn on synchronous mode
crt.Screen.Synchronous = True

' login name
crt.Screen.WaitForString "ogin:"
crt.Screen.Send "userid" & VbCr

' password
crt.Screen.WaitForString "assword:"
crt.Screen.Send "passwd" & VbCr

' find machine name
crt.Screen.WaitForString "$ "
crt.Screen.Send "uname -n" & VbCr
crt.Screen.WaitForString "$ "
row = crt.Screen.CurrentRow -1
mach = Trim(crt.Screen.Get(row,1,row,20))

' decide if more commands are needed
Select Case mach
Case "bldsrv9"
crt.Screen.Send "cd blddir" & VbCr
crt.Screen.WaitForString "$ "
crt.Screen.Send ". ./.bldprof9" & VbCr
crt.Screen.WaitForString "$ "
crt.Screen.Send "cd $MYNODE" & VbCr
Case "bldsrv10","bldsrv11"
crt.Screen.Send "cd blddir" & VbCr
crt.Screen.WaitForString "$ "
crt.Screen.Send ". ./.bldprof10" & VbCr
crt.Screen.WaitForString "$ "
crt.Screen.Send "cd $MYNODE" & VbCr
End Select

' setup the test servers (names start with tstsrv)
If Left(mach,6) = "tstsrv" Then
crt.Screen.Send ". ./.tstprofile" & VbCr
crt.Screen.WaitForString "$ "
End If

' turn off synchronous mode
crt.Screen.Synchronous = False

End Sub

'~~~~~~~~~~~~~~~~~~~~ MultiSessionLogin.vbs ~~~~~~~~~~~~~~~~~~~~~~~~~~

Tell us what you think. Did you find this tip useful? Do you have a question you'd like us to answer? Send your comments and questions to VanDyke Software Support.

1.  Read or download one of our secure solutions white papers. 2.  Download a free
30-day evaluation copy of our products.
3.  Let us help define the right Secure Shell solution for your company. 4.  Subscribe to our monthly newsletter for tips, solutions ideas, and product news.