• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating an environment variable from AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Creating an environment variable from AppleScript
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Creating an environment variable from AppleScript (From: Steve Hayman <email@hidden>)
 >RE: Creating an environment variable from AppleScript (From: "Kumar Shailove" <email@hidden>)
 >Re: Creating an environment variable from AppleScript (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Renaming a copied file with Finder
  • Next by Date: Re: Renaming a copied file with Finder
  • Previous by thread: Re: Creating an environment variable from AppleScript
  • Next by thread: Re: Creating an environment variable from AppleScript
  • Index(es):
    • Date
    • Thread