| | #16 | |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | Quote:
| |
| |
| | #17 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | woohoo got script modded and working; incase anyone is interested: Code: @echo off :loop ping www.google.com -n 1 | find "reply from" /i > log.txt wget http://192.168.1.1/cgi-bin/webcm?get...odemstatus.htm --no-proxy --output-document=modemstatus.htm strings -a -q modemstatus.htm > fixedstatus.htm echo go script: cscript getinfo.vbs del modemstatus.htm del fixedstatus.htm echo waiting... start /w wait 60 goto loop Code: 'on error resume next
routerpage="fixedstatus.htm"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
function findexp(exppattern,string)
dim objRegExp
set objRegExp = New RegExp
objRegExp.Pattern = exppattern
objRegExp.IgnoreCase = True
ObjRegExp.Global = True
set objMatches = objRegExp.Execute(string)
dim itemx,htmlstr2
' Show all the matching HTML:
For Each Itemx in objMatches
htmlstr2=htmlstr2 & Itemx.Value
Next
findexp=htmlstr2
end function
Set fso = CreateObject("Scripting.FileSystemObject")
set MyFile = fso.OpenTextFile("e:\dlink\log.txt", ForReading)
set router = fso.opentextfile("e:\dlink\" & routerpage, ForReading)
pingreply = MyFile.Readline
routerhtml= router.Readall
router.close
myfile.close
'wscript.echo pingreply
if (instr(1,pingreply,"ms",1)> 0) then
' connection is up
pingarray=split(pingreply," ")
ping_time_temp=split(pingarray(4),"=")
ping_time=ping_time_temp(1)
result= "UP!," & date & "," & time & "," & ping_time & ","
else
' connection is down
result= "DOWN!," & date & "," & time & ",,"
end if
'so lets see about the router page
'wscript.echo ">" & routerhtml
'find matches
deletecrap = findexp("<td nowrap class='tabdata'>(.*?)<\/td>",routerhtml)
'wscript.echo deletecrap
deletecrap=replace(deletecrap,"<td nowrap class='tabdata'>"," ")
deletecrap=replace(deletecrap,"</td>","#")
deletecrap=replace(deletecrap,"","")
deletecrap=replace(deletecrap,"(Kbps)","")
'wscript.echo deletecrap
crazyarray=split(deletecrap,"#")
for i = 0 to ubound(crazyarray)
'wscript.echo (i & ": " & crazyarray(i))
crazyarray(i)=trim(crazyarray(i))
next
' #1 upstream rate
' #3 downstream rate
' #5 US margin
' #7 ds margin
' #11 LOS errors
' #13 DS attenuatuation
' #15 US attenuation
' #17 path mode
header="Status,date,time,ping,"
header=header & "UP Sync,Down Sync,US Margin,DS Margin,LOS errors,DS Attenuation,US Attenuation,Path mode"
result = result & crazyarray(1) & "," & crazyarray(3) & "," & crazyarray(5) & "," & crazyarray(7) & ","
result = result & crazyarray(11) & "," & crazyarray(13) & "," & crazyarray(15) & "," & crazyarray(17)
If (fso.FileExists("e:\dlink\results.csv"))Then
set outputfile=fso.OpenTextFile("e:\dlink\results.csv", ForAppending, True)
else
set outputfile=fso.OpenTextFile("e:\dlink\results.csv", ForWriting, True)
outputfile.writeline header
end if
outputfile.writeline result
outputfile.close
wscript.echo result
|
| |




