I am running a script from my site that turns RSS feeds into HTML that is then displayed on my site. I had it working fine for quite some time now (thanks to some help from the users of <a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=11499&hl=" target="_blank">this thread</a>). I was one of the unfortunate sites affected by TCH's hard drive crash a few days ago. Everything seems to have survived the restoration process just fine (save for a few days content gone) with the exception of the RSS feed script, which has ceased functioning.<br /><br />Here is the script: <a href="http://www.filmrot.com/cgi-bin/rss2html.pl" target="_blank">http://www.filmrot.com/cgi-bin/rss2html.pl</a><br /><br />And here is where I got the script / what it looks like when it is working: <a href="http://mikeshea.net/scripts/rss2html.pl" target="_blank">http://mikeshea.net/scripts/rss2html.pl</a><br /><br />I have set the permissions on the script and the "cache" folder to "777" using CPanel's File Manager.<br /><br />For reference, this is how the script reads:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/local/bin/perl<br /># RSS parser written by Mike Shea in May 2003.<br /># Contact Mike at <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><br /># Description: Â This script takes in an RSS file and outputs a simple XHTML list. Â <br /># Passing it a "rss_url=" CGI variable will return an XHTML list of items.<br /># It works with both RSS 0.91 files as well as 2.0 files.<br /># To Do:<br /># - Add in support for <xhtml:body> in RSS 2.0 files<br /># - Perhaps wire this into a newsfeed system for the setup, fetching, and display<br /># Â of various RSS files.<br /># - Automatically create cached versions of the HTML output and offer up a URL?<br />#<br /># example use: Â http://mikeshea.net/xml/rss2html.pl?rss_url=http://mikeshea.net/articles.xml<br />#<br /><br /># Load modules, available via cpan.org<br />use SOAP::Lite;<br />use CGI qwstandard);<br />use XML::RSS;<br />use LWP::Simple;<br /><br /># start an HTML header to the client<br />print header;<br /><br /># if this is called without a parameter, display a form to enter an RSS url<br />if (!param()) {<br />print start_html('RSS Parser'),<br /> Â h1('RSS Parser');<br />print "<p>Enter RSS URL</p>";<br />print "<br /><form action=\"rss2html.pl\"><br /><input type=\"text\" name=\"rss_url\" size=\"40\" /><br /><input type=\"submit\" /><br /></form><br />";<br />print end_html;<br />exit (0);<br /><br />} else {<br /># If this is called with a parameter, we launch the parser and output HTML<br /><br /># load up the RSS url<br />my $rss_url = param('rss_url');<br /><br />#RSS Filename is the URL without http:// in it and replacing "/" with "-" and within the ./cache/ directory.<br />my $rss_filename = $rss_url; <br />$rss_filename =~ s/http:\/\///ig; # get rid of "http://"<br />$rss_filename =~ s/\//-/ig; # change "/" to "-"<br />$rss_filename = "./cache/".$rss_filename; # add ./cache/ to the directory<br /><br /># Fetch the RSS feed.<br /># check for a local version of the file:<br /># if it exists, check to see if it is under 30 minutes old<br /><br /># calculate file modified time and get a var for 30 minutes ago<br />($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($rss_filename);<br /><br />my $rss_source;<br /><br />if ($mtime >= time() - 1800) {<br /> # if it exists and is under 30 minutes old, use this file and put it in our var.<br /> open (RSSFILE, "$rss_filename") or die print "cannot open file";<br /> undef $/; # allow a single variable to take in an entire filehandler, from Perl Cookbook<br /> $rss_source = <RSSFILE>; # suck in the file into $rss_source<br /> close (RSSFILE);<br /> # print "file found"; # Check to make sure caching works<br />} else {<br /># print "file not found, fetching URL"; # Check to make sure caching works<br /># if it either does not exist or is older than 30 minutes fetch the file<br />$rss_source = get("$rss_url");<br /># and save it locally.<br />open (RSSFILE, "> $rss_filename") or die print "unable to write file $rss_filename";<br /><br />my $rss = new XML::RSS; # begin a new XML RSS instance<br />$rss->parse($rss_source) or die "cannot parse XML file"; # Parse it<br /><br /># Start displaying the HTML result. Â This output is XHTML with symantic tagging, use a stylesheet to make it look good.<br /># print RSSFILE "<h2><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/\"$rss->{'channel'}->{'link'}\" title=\"$rss->{'channel'}->{'description'}\">$rss->{'channel'}->{'title'}</a></h2>\n";<br />print RSSFILE "<ul>\n";<br /><br /># Print each item<br />foreach my $item (@{$rss->{'items'}}) {<br /> next unless defined($item->{'title'}) && defined($item->{'link'});<br /> # $item->{'description'} = "";<br /> Â $item->{'description'} =~ s/[^A-Za-z0-9 ,\.:'\/\\-]//ig; # Parse out weird characters<br /> Â print RSSFILE "<li><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/\"$item->{'link'}\" title=\"$item->{'description'}\" target=\"_blank\">$item->{'title'}</a></li>\n";<br /> }<br />print RSSFILE "</ul>\n";<br />close (RSSFILE);<br />open (RSSFILE, "$rss_filename") or die print "cannot open file";<br />undef $/; # allow a single variable to take in an entire filehandler, from Perl Cookbook<br />$rss_source = <RSSFILE>; # suck in the file into $rss_source<br />close (RSSFILE);<br />}<br /><br />print $rss_source;<br /><br />exit (0);<br />}<!--c2--></div><!--ec2--><br /><br />Any help is greatly appreciated <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><br /><br />--James (aka "melt" on Film Rotation - <a href="http://www.filmrot.com)" target="_blank">http://www.filmrot.com)</a><!--content-->
mediamelt<br /><br />in that same thread the last thing that TCH-Rick adds is <br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />have you tried this ?<!--content-->
I was going to say that the problem was the permissions as permissions on perl scripts should be 755 and not 755. The permissions are correct, however. <br /><br />I have added XML::RSS to the server as it had been added previously. The script needs that module and it is not installed by default. <br /><br />The file can also be added to your MT includes which will prevent problems should the account be moved to another server (or as in this case Perl is rebuilt.)<!--content-->
Dudes, that so worked. You guys rock so much ass. I bow before you and your quick replies.<br /><br />Thanx!<br /><br />--James (aka "melt" on Film Rotation - <a href="http://www.filmrot.com)" target="_blank">http://www.filmrot.com)</a><!--content-->
mediamelt<br /><br />in that same thread the last thing that TCH-Rick adds is <br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />have you tried this ?<!--content-->
I was going to say that the problem was the permissions as permissions on perl scripts should be 755 and not 755. The permissions are correct, however. <br /><br />I have added XML::RSS to the server as it had been added previously. The script needs that module and it is not installed by default. <br /><br />The file can also be added to your MT includes which will prevent problems should the account be moved to another server (or as in this case Perl is rebuilt.)<!--content-->
Dudes, that so worked. You guys rock so much ass. I bow before you and your quick replies.<br /><br />Thanx!<br /><br />--James (aka "melt" on Film Rotation - <a href="http://www.filmrot.com)" target="_blank">http://www.filmrot.com)</a><!--content-->