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
Sponsored Links
Old 14-12-2006, 11:03 PM   #1
 
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 am i going mad?

got a script that retrieves router stats. need to modify it for a dlink router.
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
produces the output 3064 from the len but thats it. please help
Attached Files
File Type: htm modemstatus.htm (2.9 KB, 17 views)
  Reply With Quote
Old 15-12-2006, 12:05 AM   #2
 
webman's Avatar
 
Join Date: Nov 2005
Location: County Durham
Posts: 5,668
uk uk durham city
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1
Rep Power: 38 webman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to all
Default Re: am i going mad?

For some reason, it seems to work if the first character of the HTML file isn't a space (which it is at the moment)
  Reply With Quote
Old 15-12-2006, 12:52 AM   #3
 
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?

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....
  Reply With Quote
Old 15-12-2006, 01:30 AM   #4
 
webman's Avatar
 
Join Date: Nov 2005
Location: County Durham
Posts: 5,668
uk uk durham city
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1
Rep Power: 38 webman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to all
Default Re: am i going mad?

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.
  Reply With Quote
Old 15-12-2006, 01:37 AM   #5
 
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?

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.
  Reply With Quote
Old 15-12-2006, 09:19 AM   #6
 
tom_newton's Avatar
 
Join Date: Sep 2006
Location: Leeds
Posts: 1,070
uk uk yorkshire
Thanks: 18
Thanked 57 Times in 49 Posts
Rep Power: 16 tom_newton is a jewel in the roughtom_newton is a jewel in the roughtom_newton is a jewel in the rough
Default Re: am i going mad?

Use perl & LWP::Simple? Better/easier than vbscript/forking AND its cross-platform,
  Reply With Quote
Old 15-12-2006, 09:32 AM   #7
 
webman's Avatar
 
Join Date: Nov 2005
Location: County Durham
Posts: 5,668
uk uk durham city
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1
Rep Power: 38 webman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to all
Default Re: am i going mad?

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.
  Reply With Quote
Old 15-12-2006, 04:27 PM   #8
 
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?

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.
  Reply With Quote
Old 15-12-2006, 05:27 PM   #9
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 1,692
Thanks: 11
Thanked 30 Times in 29 Posts
Rep Power: 15 mac_shinobi has a spectacular aura aboutmac_shinobi has a spectacular aura about
Default Re: am i going mad?

check this out :

http://www.codingforums.com/archive/...p?t-30994.html
  Reply With Quote
Old 15-12-2006, 06:01 PM   #10
 
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?

that seems a bit complicated. i already have a working method of extracting the data. im not really looking to change that. thx.
  Reply With Quote
Old 15-12-2006, 06:29 PM   #11
 
webman's Avatar
 
Join Date: Nov 2005
Location: County Durham
Posts: 5,668
uk uk durham city
Thanks: 105
Thanked 87 Times in 71 Posts
Blog Entries: 1
Rep Power: 38 webman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to allwebman is a name known to all
Default Re: am i going mad?

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.
  Reply With Quote
Old 15-12-2006, 08:06 PM   #12
 
PiqueABoo's Avatar
 
Join Date: Jan 2006
Posts: 531
Thanks: 2
Thanked 20 Times in 16 Posts
Rep Power: 11 PiqueABoo will become famous soon enoughPiqueABoo will become famous soon enough
Default Re: am i going mad?

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.
  Reply With Quote
Old 15-12-2006, 09:08 PM   #13
 
ChrisH's Avatar
 
Join Date: Jun 2005
Location: East Lancs
Posts: 3,982
uk uk lancashire
Thanks: 3
Thanked 43 Times in 37 Posts
Rep Power: 22 ChrisH has a spectacular aura aboutChrisH has a spectacular aura aboutChrisH has a spectacular aura about
Default Re: am i going mad?

Can you not get anything from SNMP? Recent updates to my bog standard Dlink APs has added that functionality. Might be worth checking out.
  Reply With Quote
Old 15-12-2006, 09:52 PM   #14
 
ajbritton's Avatar
 
Join Date: Jul 2005
Location: Wandsworth
Posts: 1,414
Thanks: 7
Thanked 15 Times in 10 Posts
Rep Power: 11 ajbritton will become famous soon enough
Default Re: am i going mad?

You could try using the Document Object Model (DOM) API to directly access the contents.
  Reply With Quote
Old 15-12-2006, 11:05 PM   #15
 
PiqueABoo's Avatar
 
Join Date: Jan 2006
Posts: 531
Thanks: 2
Thanked 20 Times in 16 Posts
Rep Power: 11 PiqueABoo will become famous soon enoughPiqueABoo will become famous soon enough
Default Re: am i going mad?

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
  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 11:20 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