Recently, I was looking through google, trying to figure out how to script my telnet session.
I also found quite a number of posts on here that were struggling with the task. Finally, I came across a freeware DLL
that can be accessed via CreateObject(). It is called w3sockets, and it is by dimac.net. The download location is
here.
Here is the location of the documentation for it.
One of the nice things about this is that it does not show a popup window at all.
One word of warning... the TimeOut value does not work, and always defaults to 20 seconds, no matter what value you put in.
Here is a script that demonstrates the use of the object to telnet to an IP address and check for the existence of MS Exchange.
fCheckExchange
Function fCheckExchange()
Dim oSocket, iErr, sSocketText
sSocketText = ""
Set oSocket = CreateObject("Socket.TCP")
oSocket.DoTelnetEmulation = True
oSocket.TelnetEmulation = "TTY"
oSocket.Host = "odin:25"
On Error Resume Next
oSocket.Open
iErr = Err.Number
If iErr <> 0 Then
fCheckExchange = 0
Exit Function
End If
sSocketText = oSocket.GetLine
oSocket.SendLine "quit"
oSocket.Close
On Error GoTo 0
fCheckExchange = 0
If InStr(sSocketText,"Microsoft ESMTP MAIL Service") <> 0 Then WScript.Echo "Exchange Found!"
End Function
Another note: There is an object by ActiveExperts, The ActiveSocket Network Communication Toolkit that does the same kind of thing, along with some other functionality. It is a nicer object, overall, but it does come with a $US140/10 computer license fee. Since I prefer to NOT pay for things if there is a free/public domain alternative, I went with w3Sockets.
EDIT(EBGREEN): Added the correction that DM added a few posts down.
<message edited by ebgreen on Thursday, July 05, 2007 4:40 AM>
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury