#!/usr/bin/perl -w # time-AGI.pl - by dual # # Reads the time on your # Asterisk box ######################## use strict; use Asterisk::AGI; # Create AGI object and declare vars my $AGI = new Asterisk::AGI; my $word; my $type; # Get time as hour, minute and AM/PM my $hour = `/bin/date +'%l'`; chomp(my $min = `/bin/date +'%M'`); chomp(my $ampm = `/bin/date +'%P'`); # Convert hour to word if ($hour == 1) {$word = "one";} elsif ($hour == 2) {$word = "two";} elsif ($hour == 3) {$word = "three";} elsif ($hour == 4) {$word = "four";} elsif ($hour == 5) {$word = "five";} elsif ($hour == 6) {$word = "six";} elsif ($hour == 7) {$word = "seven";} elsif ($hour == 8) {$word = "eight";} elsif ($hour == 9) {$word = "nine";} elsif ($hour == 10) {$word = "ten";} elsif ($hour == 11) {$word = "eleven";} else {$word = "twelve";} # Say morning, afternoon or evening if ($ampm eq 'am') { $type = "morning"; } elsif ($hour < 6 || $hour == 12) { $type = "afternoon"; } else {$type = "evening";} # Read the time $AGI->exec('AGI',"festival-script.pl|\"It is now $word $min in the $type.\"");