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 bpence, Oct 10, 2014 11:45 am
info in Configuration issues by sukys, Jul 21, 2014 04:30 pm
info in AbsoluteTelnet General by bpence, Jun 30, 2014 06:56 pm
info in AbsoluteTelnet General by bpence, Jun 04, 2014 12:28 pm
info in Secure Shell by bpence, Apr 15, 2014 01:37 pm
I've tried lots of different telnet/ssh clients, and I have two long-time favorites: Putty and Absolute Telnet. Putty, because it's such a quick download that on someone else's machine i can run it without going through an install, and it runs ssh. But for my own machine, the only choice is Absolute Telnet. It stores my password, terminal appearance and connection settings so that it's literally 2 seconds from clicking the icon to being logged in to my remote ssh accounts. It's incredibly customizeable, but not overwhelmingly so. I hardly ever pay for software (I'm embarassed to say), but I like Absolute Telnet so much I've paid for the full version and I'm glad I did. It's important to note that this software is maintained by one guy, Brian Pence, who personally answers people's questions on his online forum and answers email inquiries (he's answered a couple of mine, and always been really helpful). I gotta say, you hardly ever get this kind of commitment and personal touch in software anymore. --Ben Wheeler