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
Category Archives: VBS

w3Socket in VBScript

Posted on April 21, 2007 by Sam T
No comments

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
  • kaTWEET!

    • Hackers, stop hacking. Got too many unread items in my feed reader.
  • 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