Just playing today and found what I thought was a wierd behavior. I have an array of server names and need their IP addresses. "ping" was a handy way to resolve them. When I supplied one host name as a test it worked, but if I run the command more than once, it gives a wierd response.

First try - displays IP address
next try - displays result from prior shell command, newline, and IP of current server

Here's the code.. I'm at a loss to explain what's happening. Appreciate any ideas - in the mean time, I'll be looking for a UDF to accomplish this. (I figured a quick hack would suffice for this "throw-away" project.)

BTW - in troubleshooting, I've commented out most of the lines in the function. The prior response is printed as soon as the ReadLine is executed.

Thanks!

Glenn

code:
 
GetIP('server1')

GetIP('server2')

GetIP('server3')

Function GetIP($Host)

Dim $RTN, $RC $Line
$RTN = 1

Shell '%ComSpec% /c ping -n 1 $Host | %SystemRoot%\System32\Find "Pinging" > %TEMP%\junk.txt'

$RC = Open(5,"%TEMP%\junk.txt",2)
If @ERROR = 0
$Line = ReadLine(5)
$GetIP= Split(Join(Split($Line,']',-1),'['), '[')[1]
Del '%TEMP%\junk.txt'
$RTN = 0
$RC = Close(5)
EndIf

Exit $RTN

EndFunction



[ 23. April 2003, 23:00: Message edited by: Glenn Barnas ]
_________________________
Actually I am a Rocket Scientist! \:D