Re: How to parse output from a command
- From: "TDM" <tdm3@xxxxxxxxxx>
- Date: Mon, 11 Jul 2005 14:54:19 -0700
This works for me on WinXp/Win2K. Keep in mind, the .Exec method
requires WSH version 5.6. I used the nslookup option only to simplify
locating the IP address of the host and not the NameServer.
Function getHostIP(strHostName)
__________________________________________________________________________
Dim result
Dim strTmp
Dim objSH
Dim strCmdToExec
Dim strMsg
Dim ss
'_______________________________________________________________________________
strCmdToExec = "nslookup -querytype=ANY " & strHostName
Set objSH = WScript.CreateObject("WScript.Shell")
Set result = objSH.Exec("%comspec% /c " & strCmdToExec & " 2>&1")
Do While Not result.StdOut.AtEndOfStream
strMsg = result.StdOut.Readline & vbCrLf
If InStr(1, LCase(strMsg), "internet address", 1) Then
ss = Split(Trim(strMsg), "=", -1, 1)
strTmp = Replace(Trim(ss(1)), vbCrLf, "")
Exit Do
End If
Loop
If strTmp <> "" Then
getHostIP = strTmp
Else
getHostIP = False
End If
End Function
TDM
<snip>
.
- Follow-Ups:
- Re: How to parse output from a command
- From: Don
- Re: How to parse output from a command
- From: Don
- Re: How to parse output from a command
- References:
- How to parse output from a command
- From: Don
- Re: How to parse output from a command
- From: Ed Thurber
- Re: How to parse output from a command
- From: Don
- How to parse output from a command
- Prev by Date: a possible way to map usb printer to lptx (untested)...
- Next by Date: Re: SMTP delivery options.
- Previous by thread: Re: How to parse output from a command
- Next by thread: Re: How to parse output from a command
- Index(es):
Relevant Pages
|