Re: Creating an environment variable from AppleScript
Re: Creating an environment variable from AppleScript
- Subject: Re: Creating an environment variable from AppleScript
- From: Philip Aker <email@hidden>
- Date: Mon, 09 Oct 2006 08:21:04 -0700
On 2006-10-09, at 05:01:47, Mark J. Reed wrote:
Can you think of an alternative solution to this? The worst one,
that I
though of is to redirect the output of AppleScript to a text file
and then
reading this value from the Perl Script.
OS X is UNIX based; there's no need for such shenanigans. You can
read the output of any program you launch directly using "pipes".
From Perl:
# Fire off the AS - which will run in parallel to the Perl
open(AS, "osascript /path/to/my/script.as|") or die "$0: couldn't run
AppleScript: $!\n";
# Now read the output of the AS. This does it one line at a time,
# but you can also read it all in as one chunk. Which is better
depends
# on what it looks like.
while (<AS>)
{
# the line of output is in $_
}
That's been my experience as well. So if there's a problem, most
likely it's in the return value of your AppleScript. It normally
should be text for scripting languages like Perl, Lua, Python, Ruby,
etc. If you want easy control, use Tcl to coordinate:
#!/bin/sh
# tcl ignores the next line \
exec tclsh "$0" "$@"
set as_result [exec /usr/bin/osascript -e {
set res to date string of (current date)
word 1 of res
}];
set pl_result [exec /usr/bin/perl -e print("$as_result");]
puts $pl_result
Philip Aker
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden