[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
[MacPerl] cron and RealAudio
Now that I have a cable modem (yes!) I am doing my part to suck as much
bandwidth as I can, forcing the telcos to make it even better, until the
point where I can suck the entire contents of Inside Macintosh from
Cupertino to my desktop in a matter of seconds.
So I listen to RealAudio every day while I work.
There are some live programs I like to listen to every week. I listen to
the Alan Keyes show (a conservative talk show host, no, I am not trying to
start a political discussion) and Garrison Keillor's Prairie Home
Companion.
I recently installed Cron on my Mac and this morning I thought, as I
watched the clock for the program to begin, I should have Cron launch it.
So I wrote this script. Every weekday morning at 10:05 a.m., this script
will run and start my RA program.
Of course, it won't work if I happen to be using MacPerl at the time, but
c'est la vie. Note that the URL of the program changes every day, so I use
Date::Format::time2str() to adjust it accordingly. Mac::Apps::Launch is on
CPAN or on my web site.
Then I just set Cron to launch the script at the right time.
#!perl -wl
use Mac::AppleEvents;
use Mac::Apps::Launch;
use Date::Format;
use strict;
my($appid, $file, $form, $evt, $rep);
$appid = 'PNst'; #id for RealPlayer
$file = "$ENV{TMPDIR}alankeyes.ram";
$form = '%m%e%y';
open(F, ">$file") || die ($!);
print F 'pnm://206.72.64.71/' . time2str($form, time()) . '.rm';
close(F);
LaunchApps([$appid], 1) or warn ($^E);
$evt = AEBuildAppleEvent('aevt', 'odoc',
typeApplSignature(), $appid, 0, 0, '') or die($^E);
AEPutParam($evt, '----', 'TEXT', $file);
$rep = AESend($evt, kAEWaitReply()) or die $^E;
AEDisposeDesc($evt);
AEDisposeDesc($rep);
unlink($file);
__END__
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== New Book: MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch