keyongtech


  keyongtech > perl > 05/2006

 #1  
05-22-06, 10:49 PM
kc68
When I execute the script below, I get the error message "No such file or
directory at simple2.pl line 21." Line 21 is the Open OUT statement.
This script parallels a tutorial script that does work and I don't see the
error. It does print to the screen if I comment out the Open OUT line.
Thanks in advance.

#!/bin/perl

use strict;

use WWW::Mechanize;

my $output_dir = "c:/training/bc";

my $starting_url = "http://clerk.house.gov/members/olmbr.html";

my $browser = WWW::Mechanize->new();

$browser->get( $starting_url );


$browser->submit();


{

open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";

print OUT $browser->content;

close OUT;

}

close PAGE;

print $browser->content;
 #2  
05-22-06, 11:00 PM
Jaime Murillo
On Monday 22 May 2006 14:49, kc68 wrote:
[..]
>
> $browser->get( $starting_url );
>> $browser->submit();
>> {

>
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";


Maybe the directory 'output_dir' does not exists. perl wont create
directories unless you tell it to by using the mkdir function.
[..]
 #3  
05-22-06, 11:08 PM
kc68
On Mon, 22 May 2006 18:00:25 -0400, Jaime Murillo <jmurill0>
wrote:

> On Monday 22 May 2006 14:49, kc68 wrote:
>
> Maybe the directory 'output_dir' does not exists. perl wont create
> directories unless you tell it to by using the mkdir function.
>

That's it: I needed $output_dir/simple2.html - missing the $ Now have to
start working on the regex as I got the page with "No matches found"
 #4  
05-22-06, 11:20 PM
John W. Krahn
kc68 wrote:
[..]
>
> $browser->get( $starting_url );
>> $browser->submit();
>> {

>
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";


Does the directory 'output_dir' exist in the current directory or did you
intend to use the variable $output_dir instead?

> print OUT $browser->content;
>
> close OUT;
>
> }
>
> close PAGE;


Where did you open the PAGE filehandle?

> print $browser->content;



John
 #5  
05-22-06, 11:23 PM
Dr.Ruud
kc68 schreef:

> my $output_dir = "c:/training/bc";
> [...]
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";


^
Maybe you meant $output_dir?
^
Similar Threads
[client 88.112.10.183] File does not exist: /srv/www/htdocs/scrape

The client in the subject is the apache server itself. What is this process and what is it looking for? This is in the apache error_log, keeps doing that every 10...

Simple scrape with perl on google news

Hi, my perl skills have become really crappy, as I hardly ever use them. But now a business problem has shown up. Anybody with good perl skills should be able to solve this...

simple File.open error

Hello, I'm going nuts with a simple error. All I want to do is open a file and stick a number in it. The error is referring to this line below. In the error, it's picking up...

Simple questions for simple 2 PC file sharing network. Simple?

Hi-- I would like to set up a _very_ simple network to just share files, see below. I have some simple questions (I bet it's not simple but we'll see). I do have...

Error 500 when I tried to screen scrape the html content from a page programatically

Hi all i'm experiencing major problems when i try to extract html content from a MCMS controlled page programatically. I keep getting the "The remote server returned an...


All times are GMT. The time now is 10:01 PM. | Privacy Policy