Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Go Back   EduGeek.net Forums > Coding and Web Development > Coding
Reply
 
LinkBack Thread Tools Search Thread Language
Old 16-12-2006, 01:52 AM   #16
 
browolf's Avatar
 
Join Date: Jun 2005
Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 browolf will become famous soon enough
Default Re: am i going mad?

Quote:
Originally Posted by PiqueABoo
The file does not begin with a space, it begins with 0x00 which is not ASCII text and is a string terminator in most languages.

If you can't persuade whatever not to put that on the front, can you sanitise the file before you read it e.g. with the sysinternals strings util:

strings -a -q modemstatus.htm > fixedstatus.htm

Fixedstatus.htm will definitely be ASCII.
woohoo that works. exactly what i was looking for. was starting asking people to make me one lol. thanks muchly :-)
  Reply With Quote
Old 16-12-2006, 02:28 AM   #17
 
browolf's Avatar
 
Join Date: Jun 2005
Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 browolf will become famous soon enough
Default Re: am i going mad?

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
  Reply With Quote
Reply

Register now for FREE and post messages!


Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
Birthday:      
Image Verification
  I agree to forum rules 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 06:55 PM.
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright EduGeek.net