#126643 - 2004-09-13 10:35 PM
Re: Problem with @IPADDRESS0
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
What does "IPconfig /all" yield?
|
Top
|
|
|
|
#126647 - 2004-09-14 09:40 AM
Re: Problem with @IPADDRESS0
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
You might as well check all of them, in case @IPADDRESS0 is consumed by a null or dial-up interface or something strange: Code:
$=Execute("Exit 0") '@@IPAddress0 = [' + @IPAddress0 + ']'? If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf '@@IPAddress1 = [' + @IPAddress1 + ']'? If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf '@@IPAddress2 = [' + @IPAddress2 + ']'? If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf '@@IPAddress3 = [' + @IPAddress3 + ']'? If @ERROR '['+@ERROR+'] '+@SERROR ? EndIf
|
Top
|
|
|
|
#126653 - 2004-09-14 01:42 PM
Re: Problem with @IPADDRESS0
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
How about using WMI to get the info?
You could get this info directly in your polling script rather that relying on this two-pass solution.
Here is an example - to get the info from another machine (providing you have sufficient privilege) just pass the machine name to the UDF as a parameter:
Code:
Break ON $=SetOption("Explicit","ON") Dim $sHost Dim $sIPAddress, $asIPAddress $sHost=@WKSTA $asIPAddress=funGetIPAddress($sHost) If @ERROR "Could not retrieve IP addresses from '"+$sHost+"'"+@CRLF "Error: ["+@ERROR+"] "+@SERROR+@CRLF Else For Each $sIPAddress in $asIPAddress "IP Address found: " $sIPAddress ? Next EndIf Function funGetIPAddress(Optional $sHost) Dim $oWMI Dim $colItems,$oItem Dim $asIPAddress,$sIPAddress If Not $sHost $sHost="." EndIf $oWMI = GetObject("winmgmts:\\" + $sHost + "\root\cimv2") If @ERROR Exit @ERROR EndIf $colItems = $oWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48) If @ERROR Exit @ERROR EndIf For Each $oItem in $colItems $asIPAddress = $oItem.IPAddress For Each $sIPAddress in $asIPAddress If $sIPAddress Redim Preserve $funGetIPAddress[UBound($funGetIPAddress)+1] $funGetIPAddress[UBound($funGetIPAddress)]=$sIPAddress EndIf Next Next Exit 0 EndFunction
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|