teknoglot:

  • Home
  • Home
  • Microsoft
    • Hyper-V
    • OpsMgr 2007
    • SQL 2005
    • SQL 2008
    • Windows XP
    • Windows Vista
    • Windows 2008
  • Linux
    • Fedora 11
    • RedHat ES
    • SLES
    • Ubuntu
  • Code
    • PowerShell
    • VBS
  • Series
    • MP Dev: TG WinAutoSvc
  • Definitions
    • System Center Operations Manager 2007
      • Classes
      • Service Model
      • Singleton
  • Technobabble
Twitter RSS

w3Socket in VBScript

Posted on April 21, 2007 by Sam T
No commentsLeave a comment

I’ve been doing quite a lot of VBScripting in a couple of projects lately. The current one requires med to connect to a couple of telnet servers and look for… stuff.
Since we’re not in VB6 och .Net i cannot simply user Winsock as normally due to the lack of licensing features in VBS/WSH.

Thankfully for me, Dimac has release a nifty little component for free that makes talking telnet in VBS very simple.

I thought that, hey! I must share this!
So here’s an example in Classic VBS:

Dim oTelnet
oTelnet = CreateObject("Socket.Tcp")

With oTelnet
.DoTelnetEmulation = True
.TelnetEmulation = "TTY"
.Host = "192.168.242.1:23"
.Open
.WaitFor "SLUSSEN login:"
.SendLine "ANiftyUsename"
.WaitFor "Password:"
.SendLine "TEHP@ssw0rd"
.WaitFor "~ #"
.SendLine "ifconfig"
MsgBox .Buffer
.Close
End With

Set oTelnet = Nothing

Not very hard at all. This one is connecting to my router (with fake user/pwd… DUH!) and there’s no support for setting the prompt type there, thus the “~ #”.
The result of running this script with correct login info gives me a popup with the routers NIC-configuration.

Categories: VBS | Tags: Script

About Sam T

I am a System Management consultant focusing mainly on System Center Operations Manager, System Center Opalis some Microsoft SQL Server and OP5. Besides doing consulting I am also an MCT and are holding both the official System Center Operations Manager courses at all levels (50028, 50216, 50231) at Cornerstone and Global Knowledge and holds customized classes at customer sites.
View all posts by Sam T→
Notice: This work is licensed under a BY-NC-SA. Permalink: w3Socket in VBScript
Intel Drivers causes old-school freezes on Windows Vista
Silly Hibernation doo-doo on WinXP

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*


question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • kaTWEET!

    • No public Twitter messages.
  • Categories

    • Code
      • PowerShell
      • VBS
    • Linux
      • Fedora 11
      • RedHat ES
      • SLES
      • Ubuntu
    • Microsoft
      • Hyper-V
      • OpsMgr 2007
      • SQL 2005
      • SQL 2008
      • Windows 2008
      • Windows Vista
      • Windows XP
    • Technobabble
  • Recent Posts

    • Virtual OpenVPN Server at Home
    • OpsMgr 2007 R2 Documentation
    • Bulk disable ACS Forwarders (with wildcards)
    • OpsMgr 2007 Connectivity Map
    • Introduction to TG WinAutoSvc v1
  • Recent Comments

    • Giulise on Installing SQL Reporting Services 2005 on Windows 2008 x64
    • Sam T on Bulk disable ACS Forwarders (with wildcards)
    • ChrisAbel on Bulk disable ACS Forwarders (with wildcards)
    • Sam T on Introduction to TG WinAutoSvc v1
    • mats on Introduction to TG WinAutoSvc v1
© teknoglot:. Proudly Powered by WordPress | Nest Theme by YChong