+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Coding Thread, am i going mad? in Coding and Web Development; got a script that retrieves router stats. need to modify it for a dlink router. attached file is file retrieved ...
  1. #1
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,524
    Thank Post
    106
    Thanked 88 Times in 74 Posts
    Blog Entries
    46
    Rep Power
    40

    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 Attached Files

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,403
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319

    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)

  3. #3
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,524
    Thank Post
    106
    Thanked 88 Times in 74 Posts
    Blog Entries
    46
    Rep Power
    40

    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....

  4. #4

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,403
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319

    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.

  5. #5
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,524
    Thank Post
    106
    Thanked 88 Times in 74 Posts
    Blog Entries
    46
    Rep Power
    40

    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.

  6. #6


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,463
    Thank Post
    866
    Thanked 845 Times in 667 Posts
    Rep Power
    195

    Re: am i going mad?

    Use perl & LWP::Simple? Better/easier than vbscript/forking AND its cross-platform,

  7. #7

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,403
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319

    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.

  8. #8
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,524
    Thank Post
    106
    Thanked 88 Times in 74 Posts
    Blog Entries
    46
    Rep Power
    40

    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.

  9. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,720
    Thank Post
    3,248
    Thanked 1,049 Times in 971 Posts
    Rep Power
    364

    Re: am i going mad?


  10. #10
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,524
    Thank Post
    106
    Thanked 88 Times in 74 Posts
    Blog Entries
    46
    Rep Power
    40

    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.

  11. #11

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,403
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319

    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.

  12. #12

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115

    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.

  13. #13
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    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.

  14. #14
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    Re: am i going mad?

    You could try using the Document Object Model (DOM) API to directly access the contents.

  15. #15

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115

    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

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •