VKontakte.DJ
forum traveling
 

Celestial Software

...better by design

Home Support Scripting Home Script Examples VBScript example: automatic login

VBScript example: automatic login

E-mail Print

The following script uses two command (WaitFor and SendText) to perform the bare minimum tasks required to perform a scripted login. 

This script could go in the login script location in Options->Properties->Scripts section if this script is specific to the session file you currently have open.  It could also go in Options->Properties->Global as the global login script if all of your logins are always performed the same.  To implement in your environment, make sure that the 'WaitFor' Functions are waiting for the proper strings.  Login prompts vary somewhat from system to system.

Sub Main
Terminal.WaitFor("login:")
Terminal.SendText("myusername"+vbNewLine)
Terminal.WaitFor("Password for")
Terminal.SendText("mypassword"+vbNewLine)
End Sub

The drawback to the script above is that if the login prompts never come, the script waits forever!  A smarter login script might resemble the script below.  It implements a fixed amount of time to wait for the prompts, then uses the return code of the Wait to determine whether or not to proceed.  The VBScript MsgBox function is used to alert the user to possible problems. 

Sub Main
DIM success
success = Terminal.WaitForTimeout ("login:" ,5000)
if  success = TRUE   then
  Terminal.SendText("myusername"+vbNewLine)
  success = Terminal.WaitForTimeout("Password:", 5000)
  if success then
    Terminal.SendText("mypassword"+vbNewLine)
  else
    MsgBox "Timed out waiting for password prompt"
  end if
else
  MsgBox "Timed out waiting for login prompt"
end if
End Sub

 

Related Links: VBScript API , Scripting Home

Last Updated on Friday, February 27, 2009 01:04 am  

Recent Forum Posts

info in AbsoluteTelnet General by hpgptj25d82, Apr 24, 2014 01:30 am
info in AbsoluteTelnet General by kmttvf30r31, Apr 24, 2014 12:51 am
info in AbsoluteTelnet General by dhlpho92i71, Apr 24, 2014 12:44 am
info in AbsoluteTelnet General by uvvzvs49z25, Apr 24, 2014 12:15 am
info in AbsoluteTelnet General by pwegoa38a10, Apr 24, 2014 12:08 am
I have been using AbsoluteTelnet for a little over a month. We use it's SecureShell abilities as a login to our character-based applications on Linux servers. The product has performed exactly as advertised. Although I've had a few issues (i.e., not knowing how to do certain things in AbsoluteTelnet), the support has been excellent and all of the issues I've encountered have been resolved quickly. -- sywyatt