Loading ...
Sorry, an error occurred while loading the content.

Updating weblogs.com

Expand Messages
  • Dan Lyke
    There s been a whole lotta whining about how hard it is to update weblogs.com. If you re a person who s seen a Perl script once, whose web pages are hosted on
    Message 1 of 1 , Oct 31, 2001
    • 0 Attachment
      There's been a whole lotta whining about how hard it is to update
      weblogs.com. If you're a person who's seen a Perl script once, whose
      web pages are hosted on a Un*x variant, and can figure out a cron job
      ("man cron" and "crontab -e"), here's a quick script which will see if
      $indexfile is newer than $testfile, if it is it will attempt to get
      from $weblogscomurl, and will rewrite $testfile so that its modified
      date is current.

      Set it up in cron to run regularly, forget that it exists.

      License: You break it, you own all resulting pieces.

      Dan
      ---------------------------------------------------------------------

      #!/usr/bin/perl -w
      use strict;
      use LWP::Simple;

      my ($testfile, $indexfile, $weblogscomurl);

      $testfile = 'replacewithsomerandomfilethatwillbeoverwritten!';
      $indexfile = 'replacewithyourindex.html';
      $weblogscomurl = 'http://yaddayaddayadda';


      die "Unable to find $indexfile\n" unless -f $indexfile;

      if ((!-f $testfile) || ((stat($testfile))[9] < (stat($indexfile))[9]))
      {
      get($weblogscomurl);
      unlink $testfile;
      open(O, ">$testfile")
      || die "Unable to open $testfile for writing\n";
      print O "Update file for $indexfile\n";
      close O;
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.