#68880 - 2002-08-08 08:25 PM
Re: Help with enhancements to Bryces wanreport script
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
I agree with Jens, it would be easier to write whole new code then try and rework my old script.... (i would have done it already... but I got to busy..... well here are some udf's I wrote.)
The ping(,{ping flags}) UDF will return what you see when you do a
shell 'ping kixtart.org -n 1 | find "TTL"' from a commandline
quote:
C:\wanreport>ping www.kixtart.org -n 1 | find "TTL" Reply from 81.17.37.55: bytes=32 time=218ms TTL=115
$reply = ping("www.kixtart.org")
code:
function Ping($ipaddress, optional $flag) dim $tempfile, $tempdata, $nul $tempfile = "" + @ticks + ".dat"
shell '%comspec% /c ping $ipaddress -n 1 $flag | find "TTL" > $tempfile' $exit=@error if not @error $nul = open(1,$tempfile) $tempdata = readline(1) $nul = close(1) del $tempfile else $tempdata = "Timeout" endif $ping = $tempdata exit($exit) endfunction
the Function Loadfile() will load the contents of the given file into an array
$array = loadfile("computers.csv") for each $thing in $array ? $thing next
code:
function loadfile($file) dim $nul,$count, $line dim $temparray[10]
if exist($file) $nul = open(1,$file) else exit(1) endif
while not @error if $count > ubound($temparray) redim preserve $temparray[ubound($temparray)+10] endif $line = readline(1) if $line <> "" $temparray[$count] = $line $count = $count + 1 endif loop
if $count > 0 redim preserve $temparray[$count-1] else redim perserve $temparray[$count] endif
$nul = close(1)
$loadfile = $temparray endfunction
Bryce
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 581 anonymous users online.
|
|
|