| Sponsored Links |
| | #1 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | attached file is file retrieved off router. the old script reads the whole file into a string. modded script refuses to do anything with said string. can't even echo it even test script wont. dont understand whats going on /cry Code: routerpage="modemstatus.htm"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
set router = fso.opentextfile("e:\dlink\" & routerpage, ForReading)
routerhtml=router.ReadAll
wscript.echo len(routerhtml)
wscript.echo routerhtml
|
| |
| | #3 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | hmm thats very strange. that could be a problem cos thats how it comes off the router using wget. it doesnt seem to want to ltrim either.... |
| |
| | #4 |
![]() Join Date: Nov 2005 Location: County Durham
Posts: 5,668
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1 Rep Power: 38 | Have you tried opening the html file in notepad? I get the "This file is not a valid text file. It may be a binary file. Convert any NULL terminators to spaces and load anyway?" message so it must be the way it's either sent by the web server or the way wget wgot it. |
| |
| | #5 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | it works for me ok in notepad. i can see the "space" the only thing im doing different in this wget from the other working script(different router) is renaming the file because on the router its called webcm?getpage=../html/status/modemstatus.htm which vbscript doesnt like either. supposing its not really a space. any thoughts on how i can get rid of it? i tried c:\>type modemstatus.htm > newmodemstatus.htm but it didnt make any difference. |
| |
| | #6 |
![]() Join Date: Sep 2006 Location: Leeds
Posts: 1,070
Thanks: 18
Thanked 57 Times in 49 Posts
Rep Power: 16 | Use perl & LWP::Simple? Better/easier than vbscript/forking AND its cross-platform, |
| |
| | #7 |
![]() Join Date: Nov 2005 Location: County Durham
Posts: 5,668
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1 Rep Power: 38 | When I tested it, I could loop through a line at a time using Do Until router.AtEndOfStream ... router.readline and it was OK. I presume you're looking for specific information from this file, so you could take this approach and just search a line at a time. |
| |
| | #8 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | i havent got time to learn perl there's more than one thing in there im after so im using regular expressions to locate several rows of information in the whole file. this kind of thing works well with webpages and tables. i've got a suggestion of using mid off another forum to extract all the string except the "space" if i can't get another to work the other option i have is telnet to the router and get it that way. |
| |
| | #9 |
![]() Join Date: Aug 2005
Posts: 1,692
Thanks: 11
Thanked 30 Times in 29 Posts
Rep Power: 15 | |
| |
| | #10 |
![]() Join Date: Jun 2005 Location: Lancashire
Posts: 594
Thanks: 5
Thanked 13 Times in 8 Posts
Rep Power: 11 | that seems a bit complicated. i already have a working method of extracting the data. im not really looking to change that. thx. |
| |
| | #11 |
![]() Join Date: Nov 2005 Location: County Durham
Posts: 5,668
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1 Rep Power: 38 | The format of that file is screwing up the opening of it using scripting. Have you considered using AutoIt to create an automated telnet type app? Something similar to this perhaps. |
| |
| | #12 |
![]() Join Date: Jan 2006
Posts: 531
Thanks: 2
Thanked 20 Times in 16 Posts
Rep Power: 11 | 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. |
| |
| | #13 |
![]() Join Date: Jun 2005 Location: East Lancs
Posts: 3,982
Thanks: 3
Thanked 43 Times in 37 Posts
Rep Power: 22 | Can you not get anything from SNMP? Recent updates to my bog standard Dlink APs has added that functionality. Might be worth checking out. |
| |
| | #14 |
![]() Join Date: Jul 2005 Location: Wandsworth
Posts: 1,414
Thanks: 7
Thanked 15 Times in 10 Posts
Rep Power: 11 | You could try using the Document Object Model (DOM) API to directly access the contents. |
| |
| | #15 |
![]() Join Date: Jan 2006
Posts: 531
Thanks: 2
Thanked 20 Times in 16 Posts
Rep Power: 11 | One byte to get rid of and: Rewrite in PERL, never mind your VBS go and read a JScript thread, rewrite to use SNMP, go look at DOM. You lot should become a development team at RM ;b |
| |







