[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Calling Frontier from MacPerl



I'm trying to call Frontier from a MacPerl script to set the time on my
Mac and am having problems when i pass a MacPerl variable to Frontier.

I'm using MacPerl because I want to use MacPerl's net::time module to
grab the time off our internal webserver. I'm using Frontier because I
want to use Frontier's clock.set() verb to set my local Mac's time to
the server's time (because i don't know how to do that directly/easily
via MacPerl).

Grabbing the remote server's time using net::time works fine. It's when
i try to pass off that time to the Frontier clock.set() command that the
script fails.

* The Frontier portion of the script works fine when I hard code a
date/time value into Frontier's clock.set() command; e.g.,
clock.set("4/1/98;20/12/00")

* The Frontier portion of the script fails when i try to pass a value to
Frontier's clock.set() using a variable instead of a literal, where the
variable was defined either via the net::time module or by my coding the
assignment of the variable by hand; i.e., $time="4/1/98;20/12/00". Note
I massage the date/time info that i get from net::time so that it meets
Frontier's syntax requirement for clock.set(). I've also manually
assigned a string that i know works with clock.set() to the variable
$time to make sure i wasn't tripping over an error in the syntax. I've
made sure that Frontier will take a variable in that context by testing
clock.set(time) in Frontier directly, where "time" is a variable with
date/time info assigned to it.

The Frontier portions of the MacPerl script are below. It's put together
from what i could understand of the AppleScript chapter of MacPerl:Power
and Ease and from looking at the Frontier.t file that ships w/the
MacPerl distribution.


This version works:
===
use Net::Time qw(inet_daytime); 
use Mac::OSA;
use Mac::Components; 
use Mac::AppleEvents; 
my($frontier, $script, $result, $time);

$frontier = OpenDefaultComponent(kOSAComponentType, "LAND") or die
"Frontier not installed";
$script = AECreateDesc "TEXT", $ARGV[0] || <<'END_SCRIPT';
clock.set("4/1/98;21:43:58")
END_SCRIPT

OSADoScript($frontier, $script, 0, "TEXT", 0) or die $^E;

print AEPrint($result), "\n";
AEDisposeDesc $result;
AEDisposeDesc $script;

CloseComponent $frontier;


This version doesn't:
===
use Net::Time qw(inet_daytime); 
use Mac::OSA;
use Mac::Components; 
use Mac::AppleEvents; 
my($frontier, $script, $result, $time);
$time="4/1/98;21:43:58";

$frontier = OpenDefaultComponent(kOSAComponentType, "LAND") or die
"Frontier not installed";
$script = AECreateDesc "TEXT", $ARGV[0] || <<'END_SCRIPT';
clock.set($time)
END_SCRIPT

OSADoScript($frontier, $script, 0, "TEXT", 0) or die $^E;

print AEPrint($result), "\n";
AEDisposeDesc $result;
AEDisposeDesc $script;

CloseComponent $frontier;

===
Thanks in advance for any ideas. If this is considered more of a
Frontier than MacPerl question, apologies for the mis-post.


Ben Ko

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch