Publish the Daily Garfield on Facebook shell script

For years now, I’m posting the daily Garfield and Dilbert comic on my Facebook page.

This is the (clumsy) script that does that:

#!/bin/sh
URLBASE="http://comics.kamens.brookline.ma.us/cgi-bin/comics?which=specified&Garfield=include&specified=Garfield&numdays=1&width=&height=&noheaders=on&reload=reload"
wget -O page.html -erobots=off ${URLBASE}/
IMGURL=`grep "assets.amuniversal.com" page.html | awk -F'"' '{print $8}' | head -1`
wget -O garfield.gif ${IMGURL}
./mail.pl garfield.gif your-mobile-FB-emailaddress "Daily Garfield"
rm -rf page.html && rm -rf garfield.gif

Since I don’t want to use Mutt or sendmail, I’m using perl and Mail::Sender:

Mail.pl:

#!/usr/bin/perl -w
# Usage: ./mail.pl attachment to-address subject
my $file = $ARGV[0];
my $tolist = $ARGV[1];
my $subject = $ARGV[2];
my $datum= `date "+%d-%m-%Y"`; # optional
use Mail::Sender;
$sender = new Mail::Sender;if ($sender->MailFile({ 
smtp => 'localhost', 
from => 'fromuser@domain.com', 
to => "$tolist", 
subject => "$subject - $datum", 
msg => " ", 
file => "$file", 
}) < 0) { 
die "$Mail::Sender::Error\n"; 
} 
print "Mail sent OK.\n";

As always, YMMV.

One thought on “Publish the Daily Garfield on Facebook shell script

Leave a Reply

Your email address will not be published. Required fields are marked *