Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

update and still no output

by RayRay459 (Pilgrim)
on Sep 08, 2001 at 01:22 UTC ( [id://111030]=perlquestion: print w/replies, xml ) Need Help??

RayRay459 has asked for the wisdom of the Perl Monks concerning the following question:

Monks,
I posted my code yesterday about using HTML::TableExtract and i guess i needed to add a few my lines to my code. I since have done so and nowl i am not getting any output from my script. Am i not calling the value to be returned? I added a print statement at the very end of my script to make sure that my script was not hanging or dying, but it didnt help. I assumed that the info from the table in the code was going to be displayed and i wanted to pipe that out to a text file, but i can't even get data to pipe out. Do i need to assign a variable to the last line to print $variable to get output. Any help would be appreciated.
thnx.
Ray
# Ray Espinoza # GetAPC.pl # This script will take a list of ip addresses of APCs and # send the desired output to a textfile. ###################################################################### #!D:\perl\bin -w use LWP::UserAgent; use HTTP::Request; use HTML::TableExtract #################################################################### +# # Asking for Output file names. #################################################################### +# #print "Enter the name of the output file:\n"; #chomp($OutFile = <STDIN>); #################################################################### +## # Opens the outfile for appending #################################################################### +## #open(OUT,">$OutFile") || die "Can't create $OutFile: $!"; #################################################################### +## # This will log into the apc and grab the html and stuff it into an # array and then i will take that array and add a new line to every # line and stuff that into a variable #################################################################### +### $ua = new LWP::UserAgent; $url = 'http://192.168.1.1/pdumaina'; #print $url; $request = new HTTP::Request('GET',$url); $request->authorization_basic('login', 'password'); $ua->timeout(10); $response = $ua->request($request); $responsecode = $response->code(); if ($responsecode != 200) { print "Failed Request: $responsecode\n"; } else { # login successful, let's get the html code into a variable @ARRAY_OF_LINES = (split "\n", $ua->request($request)->as_stri +ng); foreach $line (@ARRAY_OF_LINES) { $html_code .= $line . "\n"; } } #################################################################### +#### # This will attempt to use HTML::TableExtract to look for these spec +ific # headers in the html tables and print out the values in the table. #################################################################### +#### $te = new HTML::TableExtract( headers => [qw(Outlet 'Device Name')] +); $te->parse($html_code); foreach $ts ($te->table_states) { print "Table (", join(',', $ts->coords), "):\n"; foreach $row ($ts->rows) { print join(',', @$row), "\n"; } } print "Done";

Replies are listed 'Best First'.
Re: update and still no output
by runrig (Abbot) on Sep 08, 2001 at 02:45 UTC
    <broken_record_mode>Use strict and warnings!</broken_record_mode>
    (not that it would have caught this problem, but just on general principle it would be a very good idea with this script).

    You appear to be attempting to look for a table named 'Device Name' but you are in fact looking for one table named 'Device and another named Name'.

Re: update and still no output
by rchiav (Deacon) on Sep 08, 2001 at 02:00 UTC
    If you're getting no output, that probably means that you don't have any data. You're on the right track by printing "Done" to see where the script is. So you know that it gets to the end..

    How about @ARRAY_OF_LINES? Have you tried printing that out? It's a fairly effective technique to throw prints in your script to figure out what's going on where.

    Unfortunately I can't help you more than that because, 1 - I'm not all that familiar with the LWP stuff (haven't had a need for it yet) and 2 - I can't run this code because of the address it's pulling from.

    Also, I thought I'd mention that you're opening a file for output.. never writing to it and never closing it either. You sould fix that.

    Rich

      I have the open output file #commented out because i wanted to fix the actual script first. I added a line
      print $html_code
      after the if/else statement and i am seeing the actual html code returned on my screen. something is not working right with the HTML::TableExtract stuff. Ray

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://111030]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-16 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found