{"id":302,"date":"2012-07-03T07:48:54","date_gmt":"2012-07-03T06:48:54","guid":{"rendered":"http:\/\/blog.campodoro.org\/?p=302"},"modified":"2012-11-21T11:35:36","modified_gmt":"2012-11-21T10:35:36","slug":"daily-garfield-dilbert-shell-script","status":"publish","type":"post","link":"https:\/\/blog.campodoro.org\/?p=302","title":{"rendered":"Publish the Daily Garfield on Facebook shell script"},"content":{"rendered":"<p>For years now, I&#8217;m posting the daily Garfield and Dilbert comic on my <a title=\" Daily Garfield Comic Strips\" href=\"https:\/\/www.facebook.com\/DailyGarfieldComicStrips\" target=\"_blank\">Facebook<\/a> page.<\/p>\n<p>This is the (clumsy) script that does that:<\/p>\n<pre>#!\/bin\/sh\r\nURLBASE=\"http:\/\/comics.kamens.brookline.ma.us\/cgi-bin\/comics?which=specified&amp;Garfield=include&amp;specified=Garfield&amp;numdays=1&amp;width=&amp;height=&amp;noheaders=on&amp;reload=reload\"<\/pre>\n<pre>wget -O page.html -erobots=off ${URLBASE}\/<\/pre>\n<pre>IMGURL=`grep \"assets.amuniversal.com\" page.html | awk -F'\"' '{print $8}' | head -1`<\/pre>\n<pre>wget -O garfield.gif ${IMGURL}<\/pre>\n<pre>.\/mail.pl garfield.gif your-mobile-FB-emailaddress \"Daily Garfield\"<\/pre>\n<pre>rm -rf page.html &amp;&amp; rm -rf garfield.gif<\/pre>\n<p>Since I don&#8217;t want to use Mutt or sendmail, I&#8217;m using perl and Mail::Sender:<\/p>\n<p><strong>Mail.pl:<\/strong><\/p>\n<pre>#!\/usr\/bin\/perl -w\r\n# Usage: .\/mail.pl attachment to-address subject<\/pre>\n<pre>my $file = $ARGV[0];\r\nmy $tolist = $ARGV[1];\r\nmy $subject = $ARGV[2];\r\nmy $datum= `date \"+%d-%m-%Y\"`; # optional<\/pre>\n<pre>use Mail::Sender;<\/pre>\n<pre>$sender = new Mail::Sender;if ($sender-&gt;MailFile({\u00c2\u00a0\r\nsmtp =&gt; 'localhost', \r\nfrom =&gt; 'fromuser@domain.com', \r\nto =&gt; \"$tolist\", \r\nsubject =&gt; \"$subject - $datum\", \r\nmsg =&gt; \" \", \r\nfile =&gt; \"$file\", \r\n}) &lt; 0) { \r\ndie \"$Mail::Sender::Error\\n\"; \r\n} \r\nprint \"Mail sent OK.\\n\";<\/pre>\n<p>As always, YMMV.<\/p>\n<div class=\"tweetthis\" style=\"text-align:left;\"><p> <a class=\"tt\" href=\"http:\/\/twitter.com\/share?url=https:\/\/blog.campodoro.org\/?p=302&text=Publish+the+Daily+Garfield+on+Facebook+shell+script+%23campodoro+%23tips+%23apple&via=goudkamp&related=richardxthripp%2Ctweetthisplugin\" title=\"Twitter\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/twitter\/tt-twitter.png\" alt=\"Post to Twitter\" \/><\/a> <a class=\"tt\" href=\"http:\/\/twitter.com\/share?url=https:\/\/blog.campodoro.org\/?p=302&text=Publish+the+Daily+Garfield+on+Facebook+shell+script+%23campodoro+%23tips+%23apple&via=goudkamp&related=richardxthripp%2Ctweetthisplugin\" title=\"Twitter\">Tweet<\/a> <a class=\"tt\" href=\"http:\/\/delicious.com\/post?url=https:\/\/blog.campodoro.org\/?p=302&amp;title=Publish+the+Daily+Garfield+on+Facebook+shell+script\" title=\"Post to Delicious\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/delicious\/tt-delicious.png\" alt=\"Post to Delicious\" \/><\/a> <a class=\"tt\" href=\"http:\/\/delicious.com\/post?url=https:\/\/blog.campodoro.org\/?p=302&amp;title=Publish+the+Daily+Garfield+on+Facebook+shell+script\" title=\"Post to Delicious\">Post to Delicious<\/a> <a class=\"tt\" href=\"http:\/\/www.facebook.com\/share.php?u=https:\/\/blog.campodoro.org\/?p=302&amp;t=Publish+the+Daily+Garfield+on+Facebook+shell+script\" title=\"Post to Facebook\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/facebook\/tt-facebook.png\" alt=\"Post to Facebook\" \/><\/a> <a class=\"tt\" href=\"http:\/\/www.facebook.com\/share.php?u=https:\/\/blog.campodoro.org\/?p=302&amp;t=Publish+the+Daily+Garfield+on+Facebook+shell+script\" title=\"Post to Facebook\">Post to Facebook<\/a><\/p><\/div>","protected":false},"excerpt":{"rendered":"<p>For years now, I&#8217;m posting the daily Garfield and Dilbert comic on my Facebook page. This is the (clumsy) script that does that: #!\/bin\/sh URLBASE=&#8221;http:\/\/comics.kamens.brookline.ma.us\/cgi-bin\/comics?which=specified&amp;Garfield=include&amp;specified=Garfield&amp;numdays=1&amp;width=&amp;height=&amp;noheaders=on&amp;reload=reload&#8221; wget -O page.html -erobots=off ${URLBASE}\/ IMGURL=`grep &#8220;assets.amuniversal.com&#8221; page.html | awk -F'&#8221;&#8216; &#8216;{print $8}&#8217; | head &hellip; <a href=\"https:\/\/blog.campodoro.org\/?p=302\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,2],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-linux","category-personal"],"_links":{"self":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/302"}],"collection":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302"}],"version-history":[{"count":6,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":2219,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions\/2219"}],"wp:attachment":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}