mediamelt Posted July 11, 2004 Share Posted July 11, 2004 I am trying to install a perl script to the server. Here is the script: >!/usr/bin/perl # RSS parser written by Mike Shea in May 2003. # Contact Mike at mike@mikeshea.net # Description: This script takes in an RSS file and outputs a simple XHTML list. # Passing it a "rss_url=" CGI variable will return an XHTML list of items. # It works with both RSS 0.91 files as well as 2.0 files. # To Do: # - Add in support for <xhtml:body> in RSS 2.0 files # - Perhaps wire this into a newsfeed system for the setup, fetching, and display # of various RSS files. # - Automatically create cached versions of the HTML output and offer up a URL? # # example use: http://mikeshea.net/xml/rss2html.pl?rss_url=http://mikeshea.net/articles.xml # # Load modules, available via cpan.org use SOAP::Lite; use CGI qw(:standard); use XML::RSS; use LWP::Simple; # start an HTML header to the client print header; # if this is called without a parameter, display a form to enter an RSS url if (!param()) { print start_html('RSS Parser'), h1('RSS Parser'); print "<p>Enter RSS URL</p>"; print " <form action=\"rss2html.pl\"> <input type=\"text\" name=\"rss_url\" size=\"40\" /> <input type=\"submit\" /> </form> "; print end_html; exit (0); } else { # If this is called with a parameter, we launch the parser and output HTML # load up the RSS url my $rss_url = param('rss_url'); #RSS Filename is the URL without http:// in it and replacing "/" with "-" and within the ./cache/ directory. my $rss_filename = $rss_url; $rss_filename =~ s/http:\/\///ig; # get rid of "http://" $rss_filename =~ s/\//-/ig; # change "/" to "-" $rss_filename = "./cache/".$rss_filename; # add ./cache/ to the directory # Fetch the RSS feed. # check for a local version of the file: # if it exists, check to see if it is under 30 minutes old # calculate file modified time and get a var for 30 minutes ago ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($rss_filename); my $rss_source; if ($mtime >= time() - 1800) { # if it exists and is under 30 minutes old, use this file and put it in our var. open (RSSFILE, "$rss_filename") or die print "cannot open file"; undef $/; # allow a single variable to take in an entire filehandler, from Perl Cookbook $rss_source = <RSSFILE>; # suck in the file into $rss_source close (RSSFILE); # print "file found"; # Check to make sure caching works } else { # print "file not found, fetching URL"; # Check to make sure caching works # if it either does not exist or is older than 30 minutes fetch the file $rss_source = get("$rss_url"); # and save it locally. open (RSSFILE, "> $rss_filename") or die print "unable to write file $rss_filename"; my $rss = new XML::RSS; # begin a new XML RSS instance $rss->parse($rss_source) or die "cannot parse XML file"; # Parse it # Start displaying the HTML result. This output is XHTML with symantic tagging, use a stylesheet to make it look good. print RSSFILE "<h2><a href=\"$rss->{'channel'}->{'link'}\" title=\"$rss->{'channel'}->{'description'}\">$rss->{'channel'}->{'title'}</a></h2>\n"; print RSSFILE "<ul>\n"; # Print each item foreach my $item (@{$rss->{'items'}}) { next unless defined($item->{'title'}) && defined($item->{'link'}); # $item->{'description'} = ""; $item->{'description'} =~ s/[^A-Za-z0-9 ,\.:'\/\\-]//ig; # Parse out weird characters print RSSFILE "<li><a href=\"$item->{'link'}\" title=\"$item->{'description'}\">$item->{'title'}</a></li>\n"; } print RSSFILE "</ul>\n"; close (RSSFILE); open (RSSFILE, "$rss_filename") or die print "cannot open file"; undef $/; # allow a single variable to take in an entire filehandler, from Perl Cookbook $rss_source = <RSSFILE>; # suck in the file into $rss_source close (RSSFILE); } print $rss_source; exit (0); } I have ASCII uploaded it to the "cgi-bin" folder on the server and Rick at TCH has guaranteed me the needed modules are on the server. Anybody know what I'm missing? Thanx in adavnce... --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Really need more information - what output are you getting? What error messages is it outputting, if any? What about the error logs (in your cpanel, there is a link to the error logs) - anything there? Have you chmodded it at all? It probably needs to be 755. That will help us to troubleshoot it. =) Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 1) Link to the script: http://www.filmrot.com/cgi-bin/rss2html.pl 2) Error I get: Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@filmrot.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. -------------------------------------------------------------------------------- Apache/1.3.31 Server at www.filmrot.com Port 80 3) Using the file manager in CPanel I have set permisions to 755 4) This shows up at the top of my error log: [2004-07-10 20:51:46]: error: file has no execute permission: (/home/freeaic/public_html/rss2html.pl) Does any of this help? --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Yes, the last error helps - try 755 or 777 permissions then try running the script again. The error says 'no execute permissions' which means something in that number is saying that its not allowed. Need to fiddle with that til you find the right thing. 777 should allow *everything* theoretically. =) Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 Permision is set to 777 and I still get the same error Anything else I could try? --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Do you have a link to the original script and installation instructions? It should say in the installation in documentation what the permissions need to be. it may also be that the script is not intended to be run alone - but as part of a site. So the originating page would be helpful. =) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Ok reading the comments in the script helps - make sure when you run it that you pass an RSS url to it, ie: http://www.filmrot.com/cgi-bin/rss2html.pl...t.org/index.rss that still gets error 500, though =/ were you trying to pass a url when you tested it with 755? Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Bleh, I can't get it to run either, I just get premature end of script headers and mines definitely in ascii and all permissions modified.. maybe someone else can chime in with this. =) ^^^ one of the many reasons I prefer php - cgi just hates me, generally speaking. Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 I got the script from here: http://www.mikeshea.net/newsfeeds/ If you don't pass a value to the script, if it's working, it should still show you this: http://www.mikeshea.net/scripts/rss2html.pl No documentation came with the source, other than the comments in the script. Is there a way I can test to make sure all those required modules are installed and working? Thanx for trying --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 Sure, if you click 'perl modules' in the left column of cpanel, it will list all of the installed modules. =) Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 Yea, they are all there as tch-Rick told me they would be. Man that guy is smart. Anybody else have any ideas? --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted July 11, 2004 Share Posted July 11, 2004 [2004-07-10 20:51:46]: error: file has no execute permission: (/home/freeaic/public_html/rss2html.pl) Have you tried putting the script into the cgi-bin folder of your public_html folder? Quote Link to comment Share on other sites More sharing options...
TCH-Rick Posted July 11, 2004 Share Posted July 11, 2004 The first line should be #!/usr/local/bin/perl or #!/usr/bin/perl. I editted that and the script is working. Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 Yea, they are all there as tch-Rick told me they would be. Man that guy is smart. I rest my case. Thanx Rick and everyone else that tried to help me! --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 11, 2004 Author Share Posted July 11, 2004 Although the script seems to be working, I'm still having a bit of trouble getting it to "really" work. When I pass the script a URL string, it errors giving me the following message: unable to write file ./cache/www.filmrot.com-index.rdfFrom what I can tell, this error comes from line 72 of the script: open (RSSFILE, "> $rss_filename") or die print "unable to write file $rss_filename"; I thought maybe I needed a "cache" directory, so I created one. Didn't seem to help. Anyone know what I may still be leaving out? Thanx in advance, --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
LisaJill Posted July 11, 2004 Share Posted July 11, 2004 is the cache directory world writable? ie 777? and is it in cgi-bin or public_html? Quote Link to comment Share on other sites More sharing options...
mediamelt Posted July 12, 2004 Author Share Posted July 12, 2004 Look slike it is working now. it wasn't earlier today, not sure why it is now - but it is. Whomever or whatever fixed it, know that I am grateful http://www.filmrot.com/cgi-bin/rss2html.pl...org%2Findex.rdf --James (aka melt on Film Rotation - http://www.filmrot.com) Quote Link to comment Share on other sites More sharing options...
TCH-Rick Posted July 12, 2004 Share Posted July 12, 2004 Sorry, I changed the permissions to 777 and then someone IM'ed me so I forgot to update this post. The error message was the clue as Lisa mentioned. The cgi-bin directory cannot be set to 777, it must be set to 755. All perl scripts must be set to 755 as well. The cache directory, however, should be set to 777 so that it can be written to. Glad it is working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.