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

Re: [MacPerl] Launching a script from another script??



At 20.15 -0400 1999.04.26, Schwartz, Todd wrote:
>1. I am using Mac::Process:LaunchApplication() to launch the background
>script.  When the first script does the launch, it appears to get completely
>blown away by the second script.  This happens whether the second script is
>saved as a droplet or as a Runtime.  I wondering whether this is a
>limitation of the Mac OS -- that only one copy of an app can be loaded at a
>time.  But I expected that a Runtime script would count as a distinct
>application which could peacefully coexist with a running copy of MacPerl.

You can only run one "copy" of MacPerl at a time.  You can physically copy
the MacPerl app and run another "copy" that way, as a runtime or something.
If your first one is getting blown away, it is probably because
LaunchApplication by default quits the calling process when it launches the
new one.  You need to set the launchDontQuit flag or somesuch.


>2. When running a script saved as a Runtime object, the @INC variable does
>not contain the standard library paths.

I think it does if it is in the same location as the MacPerl app.  If not,
you will have to add those paths manually to the preferences, I think.
Easiest maybe to just keep the runtime in the same location and make
aliases elsewhere.


>3. There appears to be no standard way to pass arguments to a launched
>application from a MacPerl script.  Since
>Mac::Processes::LaunchApplication() does not provide any way to pass
>arguments via the command-line, I decided to try setting an environment
>variable, but the environment does not seem to get passed to the launched
>application.

Correct.  What you could possibly do is launch the new MacPerl app and then
try to send it a Do Script command:

  tell app "path:to:MacPerl copy"
    Do Script {alias "path:to:myscript", "these", "go", "in", "@ARGV"}
  end tell

>Will MPW solve my problems?  Am I barking up the wrong tree?

The problem with talking to MPW from MacPerl here is that the original
script will wait for the MPW perl to finish before continuing ... I don't
know of a way around it.  The above could work.

Easiest here to just execute it as text with the MacPerl::DoAppleScript()
function, though you could convert it into raw Apple events ... the problem
with that is raw Apple events are easiest by just using the creator ID,
which in this case won't be unique, since you have to copies of MacPerl
running, so best to just use the AppleScript.  You could use Mac::Processes
to get the PSN of the MacPerl copy app and then use it as your target and
typeProcessSerialNumber as your target type for the Apple event, though, if
you wanted to.  If none of this makes sense, use MacPerl::DoAppleScript.  :)

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org