mediamelt
Members-
Posts
16 -
Joined
-
Last visited
Everything posted by mediamelt
-
Perl Script Was Working, Sever Hd Crashed, Now...
mediamelt replied to mediamelt's topic in Scripting Talk
Dudes, that so worked. You guys rock so much I AM A SPAMMER. I bow before you and your quick replies. Thanx! --James (aka "melt" on Film Rotation - http://www.filmrot.com) -
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 this thread). 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. Here is the script: http://www.filmrot.com/cgi-bin/rss2html.pl And here is where I got the script / what it looks like when it is working: http://mikeshea.net/scripts/rss2html.pl I have set the permissions on the script and the "cache" folder to "777" using CPanel's File Manager. For reference, this is how the script reads: >#!/usr/local/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'}\" target=\"_blank\">$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); } Any help is greatly appreciated --James (aka "melt" on Film Rotation - http://www.filmrot.com)
-
...and I had over 60 of them Anyone know of a faster way to add cron jobs than one by one? ... very tedious. Also, is it possible to backup the cron jobs? Are the jobs located in a text document somewhere on the server so I can edit directly instead of through CPanel? Any help is appreciated --James (aka melt on Film Rotation - http://www.filmrot.com)
-
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)
-
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: From what I can tell, this error comes from line 72 of the script: 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)
-
I rest my case. Thanx Rick and everyone else that tried to help me! --James (aka melt on Film Rotation - http://www.filmrot.com)
-
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)
-
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)
-
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)
-
1) Link to the script: http://www.filmrot.com/cgi-bin/rss2html.pl 2) Error I get: 3) Using the file manager in CPanel I have set permisions to 755 4) This shows up at the top of my error log: Does any of this help? --James (aka melt on Film Rotation - http://www.filmrot.com)
-
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)
