Menu

SwitchMap.pl error after 13.1 upgrade "no /td in remainder"

SVig
2014-05-01
2015-12-16
  • SVig

    SVig - 2014-05-01

    Hey guys, after moving to 13.1, we're now getting this error when we try to search for something using SwitchMap.pl:

    Prototype after '@' for main::SearchHtmlRow : @$ at FindOffice.pl line 157
    no /td in remainder!!! at FindOffice.pl line 106, <INHTMLFILE> line 162

    I found one thread about the Prototype error and "solved" that following the suggestion to remove the definition, but can't figure out the no /td error.

    Any ideas? We're on Ubuntu 13.04 and Perl v5.14.2
    Thanks
    -S

     
  • Pete Siemsen

    Pete Siemsen - 2014-05-01

    The first error, about the prototype, indicates that you are using an
    older version of Perl - one that doesn't understand the prototype
    syntax. It's ok to remove the definition. I assume that you mean you
    deleted just the "(@$)" on line 157, right?

    The second error, about the "/td", indicates that FindOffice.pl is
    failing to parse the HTML that was produced by SwitchMap.pl. This
    shouldn't happen, because the HTML produced by SwitchMap.pl should be
    well-formed, meaning that a "" can be found following every
    "". If you'd like to debug it, I can suggest how to do so, but
    it's a bit strange because of the CGI nature of things. Want to try?

     
  • SVig

    SVig - 2014-05-02

    Thanks for the prompt response.

    Correct. Just removing "(@$)" on line 157 per a different post at least removes the error from outputting. I'll upgrade Perl shortly, but it seems to work fine without it.

    After seeing your comment I made the assumption that I still had some older files lying about that must have been produced with 13.0. I blew out all files in the VAR and DestinationDirectory directories and reran everything. After that it's working as expected.

    Thanks again. All good now.
    -S

     
  • SVig

    SVig - 2014-05-09

    Well... I spoke too soon. The issue is back.

    I re-cleared all my generated files and reran with just a few core switches and it works fine. Then I added in a handful of HP switches that I added after the 13.1 release and have identified that the issues is being caused by a couple specific HP Switch 3500yl-48G(J8693A) switches. Oddly, a different switch of the same type does not cause this error.

    Let me know what I can do/provide to help debug.

    Thanks
    -Steffan

     
  • SVig

    SVig - 2014-05-12

    Attached is a copy of one of the HTML files that the CGI script is having issues with.
    Thanks
    -S

     
  • Stuart Kendrick

    Stuart Kendrick - 2015-11-29

    I'm seeing the same "no /td in remainder" error

    vishnu:/usr/lib/cgi-bin> ./FindOffice.cgi
    CGI::Pretty is DEPRECATED and will be removed in a future release. Please see ht
    tps://github.com/leejo/CGI.pm/issues/162 for more information at /opt/local/lib/
    perl5/site_perl/5.20.1/CGI/Pretty.pm line 19.
    Name "CGI::Pretty::AS_IS" used only once: possible typo at ./FindOffice.cgi line
    35.
    no /td in remainder!!! at ./FindOffice.cgi line 106, <INHTMLFILE> line 492.
    vishnu:/usr/lib/cgi-bin>

    I'm using Cat2960X, Nexus 9300, and HP 2510 switches.

    I can see that this message is triggered by GetCellContents in FindOffice

    sub GetCellContents ($) {
    my $Html = shift;
    die "no td!!!" if $Html !~ /^<td(<span>[^>]*)?>/;
    my $Remainder = $';
    die "no /td in remainder!!!" if $Remainder !~ /<\/td>$/;
    [...]

    Seems to me that 'die' executes because a line of HTML which begins with '' does not end with '</td'.

    So, doing a little grepping:
    vishnu> grep "" p1n-esx.html | grep -v "<\/td>"
    vishnu>
    p1n-esx is a Cat2960X

    How about poking at an HTML file associated with an HP-2510?

    vishnu> grep "" dc-mgmt-1-esx.html | grep -v "<\/td>"
    Binary file dc-mgmt-1-esx.html matches
    vishnu>

    That's weird. Well, let's push through with the grep:

    vishnu> grep -a "" dc-mgmt-1-esx.html | grep -v "<\/td>"
    vishnu>

    How about checking all the .html files:
    vishnu> grep -a "" *.html | grep -v "<\/td>"
    vishnu>

    The output from this last grep suggests that all lines which start with "" also end with "", i.e. I don't see a hint of malformed HTML here.

    However, why do the .html files associated with HP-2510 switches look like 'binary' files to Linux?

    vishnu> file dc-mgmt-1-esx.html
    dc-mgmt-1-esx.html: data
    vishnu>

    When I edit the file, vim reports the following in the status line:
    "dc-mgmt-1-esx.html" [converted] 984L, 41813C

    Which suggests that the HP .html files are being written using some encoding other than whatever my default is. What is my default?

    vshnu> set | grep LANG
    LANG=en_US.UTF-8
    vishnu>

    Looks like UTF.

    So why is p1n-esx.html interpreted as UTF-8 while dc-mgmt-1-esx.html is not?

    vishnu> diff p1n-esx.html dc-mgmt-1-esx.html
    8c8
    < p1n-esx ports list


    dc-mgmt-1-esx ports list
    [...]

    Looks like all the beginning lines are identical between the two, only diverging once we reach the line specifying the name of the switch.

    Where might the problem lie?

    vishnu> iconv -f utf-8 -t utf-8 dc-mgmt-1-esx.html > /dev/null
    iconv: illegal input sequence at position 19440
    vishnu>

    OK, so let's edit this file and look at position 19440:
    vishnu> vi dc-mgmt-1-esx.html
    :goto 19440

    <nobr>Cisco Nexus Operating System (NX-OS) Software 7.0(3)I2(1)/ /TAC support: http://www.cisco.com/tac//Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.</nobr>
    CB1<90>q C8

    OK, not obvious from my text above, but position 19440 lands on the 'C' in the string 'CB1'

    Hmmm, OK, so how does the string "CB1<90>q\nC8" get inserted into this .html file?

    Tips on how to pursue this further?

    --sk

     
  • Pete Siemsen

    Pete Siemsen - 2015-12-01

    Well first off, I don't like the warning about CGI::Pretty being deprecated. To fix that at least, I hacked my latest version of FindOffice.pl to remove references to CGI:Pretty, without affecting the output. So that'll be fixed for good in the next release of SwitchMap.

    Why is your file named FindOffice.cgi? Just curious.

    FindOffice.pl operates by parsing HTML files that are produced by switchmap.pl. FindOffice.pl assumes that switchmap.pl produces well-formed HTML files. If the HTML is badly formed, FindOffice.pl just dies. It might be nice if it produced a better error message than "no /td in remainder!!!", but the condition is never supposed to happen.

    To debug your problem, I've hacked the attached FindOffice.pl so that when it encounters the condition, it outputs a message to STDERR. The message should show the HTML file name and the fragment of HTML that is malformed. Doing this is a temporary hack - I don't want the bad HTML to ever be part of a real error message. This is a CGI program, so the output has to be valid HTML, even when the output is just an error message. So let's try this, hopefully find and fix the bug, and then I'll delete the temporary hacks I've installed.

    Also in this version, I made in use "warn" instead of "die", so it'll write to STDERR, and then blindly forge on instead of dying. In other words, it tries to ignore the bad HTML.

    None of this addresses the real problem that you pointed out: how did that bogus string get into dc-mgmt-1-esx.html? Good question. The file was created by switchmap.pl, which shouldn't produce bad HTML. Perhaps the problem is in switchmap.pl Let's see if the debugging I added helps narrow it down.

    Cheers.

     
  • Stuart Kendrick

    Stuart Kendrick - 2015-12-08

    FindOffice.cgi -- a habit I've acquired, for cueing the admin as to which scripts are running via the CGI mechanism. Since these days I dump all CGI scripts into a directory named 'cgi-bin', this habit has become redundant ...

    The browser returns:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    And here is the output from the hacked version of FindOffice:

    vishnu> env QUERY_STRING="strng=vishnu" ./FindOffice.cgi
    Content-type: text/html
    <!doctype html>
    <html>
    <head>
    Search Results
    <link href="/switchmap/SwitchMap.css" rel="stylesheet" type="text/css">
    </head>
    <body>

    Search Results


    in /var/www/html/switchmap/switches/dc-mgmt-1-esx.html: table cell doesn't end w
    ith "</td>", ignoring
    bad cell content: <nobr>Cisco Nexus Operating System (NX-OS) Sof
    tware 7.0(3)I2(1)//TAC support: http://www.cisco.com/tac//Copyright (c) 2002-201
    5, Cisco Systems, Inc. All rights reserved.</nobr>
    ? 1986-2015 by Cisco Syste
    ms, Inc.//Compiled Tue 28-A</nobr>
    eI
    in /var/www/html/switchmap/switches/dc-mgmt-1-esx.html: table cell doesn't start
    with "<td>", ignoring
    bad cell content: @
    in /var/www/html/switchmap/switches/dc-mgmt-2-esx.html: table cell doesn't end w
    ith "</td>", ignoring
    bad cell content: <nobr>Cisco Nexus Operating System (NX-OS) Sof
    tware, Version 7.0(3)I2(1)N9K-C9372TX</nobr>
    ?/switches/dc-mgmt-3-esx.html: t
    able cell doesn't start with "<td>", ignoring
    bad cell content:
    in /var/www/html/switchmap/switches/mdf-mgmt-1-esx.html: table cell doesn't end
    with "</td>", ignoring
    bad cell content: <nobr>Cisco IOS Software, IOS-XE Software, Cat
    alyst 4500 L3 Switch Software (cat4500e-UNIVERSALK9-M), Version 03.07.01.E RELE
    ASE SOFTWARE (fc3)//Technical Support: http://www.cisco.com/techsupport//Copyrig
    ht (c) 1986-2015 by Cisco Systems, Inc.//Compiled Tue 28-A</nobr>
    eI
    in /var/www/html/switchmap/switches/mdf-mgmt-1-esx.html: table cell doesn't star
    t with "<td>", ignoring
    bad cell content: @



    Switch 6s-1-esx

























    <td

    6S-1-esx Access Port


    Port information
    information about the port itself information about what the port is connected to
    Port VLAN State Days
    Inactive
    Speed Duplex Port Label What
    (via CDP)
    MAC Address NIC
    Manufacturer
    IP Address DNS Name
    Gi2/0/3772Active 1Gfull  448a5bc0fcc9<
    /td>
    Micro-Star INT'L10.128.72.
    11
    vishnu





    This web page was generated by the "FindOffice" program (version 13.1) on 2015-1
    2-08 at 05:19:20.

    The program is available at

    http://sourceforge.net/projects/switchmap/


    </body>
    </html>
    vishnu>

     
  • Stuart Kendrick

    Stuart Kendrick - 2015-12-11

    Hi Pete -- I don't see an attachment to the above post -- would you try again? --sk

     
  • Pete Siemsen

    Pete Siemsen - 2015-12-14

    Sorry, here it is.

     

    Last edit: Pete Siemsen 2015-12-14
  • Stuart Kendrick

    Stuart Kendrick - 2015-12-15

    Yes, the Seach Ports function works now, thank you.

    Let me know if there is more I can do to help make SwitchMap better -- I appreciate your effort in providing this product to the community. I'd be happy to try out future debug / test versions of FindOffice.pl, for example.

     
    • Pete Siemsen

      Pete Siemsen - 2015-12-16

      Glad it works, and thanks for the offer of help. I may take you up on it
      soon. I'm working on the next release, which will involve a bit more
      complexity during installation. I'd like a friendly tester to try it, so I
      don't get swamped with complaints about problems. I'll let you know.

      Cheers,

      -- Pete

      On Tue, Dec 15, 2015 at 6:21 AM, Stuart Kendrick skendric@users.sf.net
      wrote:

      Yes, the Seach Ports function works now, thank you.

      Let me know if there is more I can do to help make SwitchMap better -- I
      appreciate your effort in providing this product to the community. I'd be
      happy to try out future debug / test versions of FindOffice.pl, for example.


      SwitchMap.pl error after 13.1 upgrade "no /td in remainder"
      https://sourceforge.net/p/switchmap/discussion/378009/thread/66a7caff/?limit=25#deaa


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/switchmap/discussion/378009/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.