Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

No Such File Error on Simple Scrape
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;



Report this thread to moderator Post Follow-up to this message
Old Post
kc68@cornell.edu
05-23-06 12:00 AM


RE: No Such File Error on Simple Scrape
One simple thing you might want to start doing is including the filename
in your error message.  Quite often this message means that either
you're not in the starting directory you think you're in or part of your
filename is being interpreted as something other than what you intended.



my $file =3D "output_dir/simple2.html";
open OUT,">$file" or die "Can't open '$file' for writing: $!";


-----Original Message-----
From: kc68@cornell.edu [mailto:kc68@cornell.edu]=20
Sent: Monday, May 22, 2006 2:50 PM
To: beginners@perl.org
Subject: No Such File Error on Simple Scrape

When I execute the script below, I get the error message "No such file
or =20
directory at simple2.pl line 21."  Line 21 is the Open OUT statement.  =20
This script parallels a tutorial script that does work and I don't see
the =20
error.  It does print to the screen if I comment out the Open OUT line.

Thanks in advance.

<snip>

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

<snip>




Report this thread to moderator Post Follow-up to this message
Old Post
Timothy Johnson
05-23-06 12:00 AM


Re: No Such File Error on Simple Scrape
On Monday 22 May 2006 14:49, kc68@cornell.edu wrote:
> 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: $!";

Maybe the directory 'output_dir' does not exists.  perl wont create
directories unless you tell it to by using the mkdir function.

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

Report this thread to moderator Post Follow-up to this message
Old Post
Jaime Murillo
05-23-06 12:00 AM


Re: No Such File Error on Simple Scrape
On Mon, 22 May 2006 18:00:25 -0400, Jaime Murillo <jmurill0@pacbell.net>
wrote:

> On Monday 22 May 2006 14:49, kc68@cornell.edu 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"


Report this thread to moderator Post Follow-up to this message
Old Post
kc68@cornell.edu
05-23-06 12:00 AM


Re: No Such File Error on Simple Scrape
kc68@cornell.edu wrote:
> 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: $!";

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
--
use Perl;
program
fulfillment

Report this thread to moderator Post Follow-up to this message
Old Post
John W. Krahn
05-23-06 12:00 AM


Re: No Such File Error on Simple Scrape
kc68@cornell.edu schreef:

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

^
Maybe you meant $output_dir?
^

--
Affijn, Ruud

"Gewoon is een tijger."



Report this thread to moderator Post Follow-up to this message
Old Post
Dr.Ruud
05-23-06 12:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:11 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.