#!/usr/bin/perl use strict; use Net::Google::Calendar; use Net::Google::Calendar::Entry; my $host = `hostname`; chop $host; if(@ARGV) { my $text = "@ARGV"; # First we add it to the local LOG file my $ts = `date '+%Y%m%d%H%M%S'`; chop $ts; `echo "$ts $text" >> ~/tlt/private/log/LOG-$host`; # Now lets add it to the google calendar my $username = 'awwaiid@gmail.com'; my $password = 'awwaiid'; my $cal = Net::Google::Calendar->new; unless($cal->login($username, $password)) { print "Error: $@\n"; die; } # Gotta select the 'Notes' calendar for ($cal->get_calendars) { $cal->set_calendar($_) if ($_->title eq 'Notes'); } # Set up the entry my $entry = Net::Google::Calendar::Entry->new(); $entry->title($text); $entry->location($host); $entry->transparency('transparent'); $entry->when(DateTime->now, DateTime->now() + DateTime::Duration->new( minutes => 1 ) ); # And finally, add it $cal->add_entry($entry); } else { print `(for i in ~/tlt/private/log/LOG-* ; do tail -20 \$i ; done) | sort | tail -20 | perl -pe 's/^(....)(..)(..)(..)(..)(..)/\$1.\$2.\$3 \$4:\$5/'`; }