MDauphinais1
asked on
Check for a remote open port
How can I ping a remote IP on a specific port to see if that port is open? I know how to do this in PHP but I can't figure it out in VBScript.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The oSocket.Host = "IP:PORT" is correct.
If a service is running on the port, the connect message will be contained in the variable 'sSocketText". Evaluate 'sSocketText" to determine if a service is running there - you can copy to text file or display to a msgbox for logging/debugging purposes.
If a service is running on the port, the connect message will be contained in the variable 'sSocketText". Evaluate 'sSocketText" to determine if a service is running there - you can copy to text file or display to a msgbox for logging/debugging purposes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob, that's perfect. Thank you.
Hi, I have tried the dll and the code which works fine, however i am looking to test if port 135 is open.
The avbove script does work by returning a empty value however it takes 30 second (in a telnet session the telnet connection is created instantly)
As a little background i ma trying to determine if an live IP address is a windows device without having credentials to access it.
Any thoughts ?
Thanks
The avbove script does work by returning a empty value however it takes 30 second (in a telnet session the telnet connection is created instantly)
As a little background i ma trying to determine if an live IP address is a windows device without having credentials to access it.
Any thoughts ?
Thanks
ASKER
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,"Microso
End Function
So say I want to check for port 1221 on an IP address, would I change this line: oSocket.Host = "odin:25" to this: oSocket.Host = "IPADDRESS:1221" ? Then which part tells me if the port is open or closed?