Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Running script at server

by juan25 (Initiate)
on Nov 23, 2004 at 15:12 UTC ( [id://409911]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, im trying to run a perl script at a company website. The script gets an url, converts some stuff we need into xml code and then generates the file, which should go in a different directory of the server. It's supposed to be called from another perl script we have on the server, and it works perfectly fine in my localhost web server, producing output and so, but when uploaded the xml file is not created. Any idea of where should i be pointing at?

So here is the code, notice im not very into perl...

#!/usr/bin/perl -w use LWP::Simple; use HTML::TokeParser; my $page= get('$url') or die("$!");#thats the webpage my $stream= new HTML::TokeParser(\$page); $file = "bestsellers.xml"; #the file,if exists I delete it unlink($file); open(f1, ">>bestsellers.xml") or die("Can't open .rss file: $!"); print f1 "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; print f1 "<rss version='0.91'>\n"; print f1 "<best>"; print f1 "<title>The title</title>\n"; print f1 "<link>$url</link>\n"; while(my $tag = $stream->get_tag("table")) { if ($tag->[1]{name} and $tag->[1]{name} eq "product") { #do the stuff for scrapping what i need and #writing it into f1 } } print f1 "</best>\n"; print f1 "</rss>\n"; close f1;

20041123 Janitored by Corion: Fixed formatting

Replies are listed 'Best First'.
Re: Running script at server
by zejames (Hermit) on Nov 23, 2004 at 15:19 UTC

    It'd be better if you provided your code.

    Anyway, the two ideas that come to my mind now are :

    • Right problem ? Are you sure you have to right to write your xml file to the filesystem on the remote Web server
    • Path problem ? Are you sure the path you use in your script (for example to know where to write) is correct ? I'd advise you to use absolute path if you run the script through cron or script, as you do not master the environnment variables and more particularly PATH.

    HTH


    --
    zejames
Re: Running script at server
by Anonymous Monk on Nov 23, 2004 at 15:15 UTC
Re: Running script at server
by ikegami (Patriarch) on Nov 23, 2004 at 16:37 UTC

    my $page= get('$url') won't work. Even if $url was defined -- it's not -- it still wouldn't work. my $page= get("$url") would work, but you want plain old my $page= get($url).

    I don't think or die("$!") works as you expect, since LWP::Simple::get doesn't set $! as far as I know. It will die as expected, however, which leads to the question: Why didn't you check for or mention error messages? This would have given you one.

      Thank you for putting some light on this, so far I've managed to get that error code from the server: Can't locate LWP/Simple.pm in @INC (@INC contains: /usr/local/nf/lib/perl5/5.6.1/i386-freebsd /usr/local/nf/lib/perl5/5.6.1 /usr/local/nf/lib/perl5/site_perl/5.6.1/i386-freebsd /usr/local/nf/lib/perl5/site_perl/5.6.1 /usr/local/nf/lib/perl5/site_perl .) at rssmaker.pl line 7. BEGIN failed--compilation aborted at rssmaker.pl line 7. Does it means that the lwp module is not installed on the server? thanks
Re: Running script at server
by rdfield (Priest) on Nov 23, 2004 at 16:04 UTC
    Have you checked the web server's log file? All of your script errors should be there.

    rdfield

Re: Running script at server
by Mutant (Priest) on Nov 23, 2004 at 15:34 UTC
    It's impossible to tell from your description of the problem, but make sure when you open the file for writing, you do something like this:
    open (FILE, '>'.$file) || die "Couldn't open $file for writing ($!)";
    This will let you know if there are any problems with permissions, paths, etc.

Log In?
Username:
Password:

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

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

    No recent polls found