Newbie perl question

L

laclac01

I am new to perl, I am having so trouble. For my program, I just want
to log in to my router and then spit out the html to the screen.
here is my code

#!/usr/bin/perl

$original ="http://admin:[email protected]/cgi-bin/sysinfo.cgi";
#$original ="README";
open (FILE, $original);
@lines=<FILE>;
close FILE;
print @lines;

When I try to do it for the file README it works fine, but when I try
it for the website it doesn't work. The address is correct because I
can cut and past it in to a browser and it brings me to the correct
page.
Any suggestions?
 
G

Gunnar Hjalmarsson

I am new to perl, I am having so trouble. For my program, I just want
to log in to my router and then spit out the html to the screen.
here is my code

#!/usr/bin/perl

$original ="http://admin:[email protected]/cgi-bin/sysinfo.cgi";
#$original ="README";
open (FILE, $original);
@lines=<FILE>;
close FILE;
print @lines;

When I try to do it for the file README it works fine, but when I try
it for the website it doesn't work. The address is correct because I
can cut and past it in to a browser and it brings me to the correct
page.
Any suggestions?

open() expects a path on the file system, not a URL.

perldoc -q fetch
 
T

Tad McClellan

Subject: Newbie perl question


Please put the subject of your article in the Subject of your article.

For my program, I just want
to log in to my router and then spit out the html to the screen.
^^^^

perldoc -q HTML

How do I fetch an HTML file?



A "URL" and a "filename" are not the same thing, so you
access them differently.

open (FILE, $original);


You should always, yes *always*, check the return value from open():

open (FILE, $original) or die "could not open '$original' $!";

Any suggestions?


Check the Perl FAQ *before* posting to the Perl newsgroup!
 
J

John Bokma

I am new to perl, I am having so trouble.


Pick your subject with care. Almost all post here are perl questions, so
no need to state such in your subject. Also we're not really interested in
your level of expertise, this is often clear from the question and/or
code.

So that leaves you with an empty subject, because it's entirely wrong.

What's your problem? You can't open a file for reading via an URL.

By just putting that in your subject it's clear what you're asking, and
people who know about that subject, are more able (and probably willing)
to help you.

In short: create the shortest post possible that describes your problem.
You are asking busy people to help you for free.
Any suggestions?

Read the documentation of LWP. Assuming you're on Windows and are
using Active State, and installed stuff in the default location, enter in
your browser:

file:///C:/Perl/html/site/lib/lwpcook.html

You might want to bookmark: file:///C:/Perl/html/index.html

Also learn to use perldoc, type in a "dos box":

perldoc perldoc

And study the output.
 
M

Michael Perle

I am new to perl, I am having so trouble. For my program, I just want
to log in to my router and then spit out the html to the screen.
here is my code

#!/usr/bin/perl

$original ="http://admin:[email protected]/cgi-bin/sysinfo.cgi";
#$original ="README";
open (FILE, $original);
@lines=<FILE>;
close FILE;
print @lines;

Without no error handling and LWP installed (I guess
it is standard in most distributins - someone may
correct me if I am wrong) that could be easy as:

use LWP::Simple;
$html = get 'http://www.vonabiszet.de/';
print $html;

MP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top