Shell and Background Jobs

Nonsanity form at
Wed Aug 24 01:04:57 EDT 2011

Okay, it's a ugly hack, but it gets the job done.

I wrote an AppleScript that fetches it's input from a text file, then calls
the Unix shell line for me, which redirects output to another text file (the
original purpose). Saved as an application.

On the LiveCode side, I write the input to the text file and then do an
"open process for neither" (or just "launch") of the AppleScript app.
Unfortunately, it comes to the front, but I'll deal with that later.
LiveCode continues to run nicely. It monitors the progress of the app with
short shell calls instead of the "open process" functions, which didn't seem
to be able to tell me when the AppleScript ended. "ps" and a "grep" or two
work fine.

When LC detects that the AppleScript has finished, it fetches the output
text file and continues with the processing. All the while, LC is also
monitoring the output of another process that WAS successfully backgrounded
using the shell() function. I don't know why THAT one works and others
don't. I'm glad it does though. It's a call to HandBrake and can take a
whole day to complete sometimes. (I've restricted it's thread use so it
doesn't hog the CPU - The price to pay for that is slowness.)

So aside from getting the AppleScript app to stay hidden when it launches -
or at least reasserting LiveCode to the foreground immediatly after it
starts - it looks like this solution will work.

I'd like to know if other people get the same results to my shell("sleep 5
&") test at the start of this thread on Macs or Linux systems. Maybe it's
just me...

 ~ Chris Innanen
 ~ Nonsanity

On Tue, Aug 23, 2011 at 5:16 PM, Nonsanity <form at> wrote:

> Okay, the Applescript intermediary sounds like it might work. I'll give
> that a go.
>  ~ Chris Innanen
>  ~ Nonsanity
> On Tue, Aug 23, 2011 at 5:14 PM, Mark Schonewille <
> m.schonewille at> wrote:
>> Hi Chris,
>> Don't believe everything that's written. I can imagine that some command
>> line apps don't work well with the open process command, but quite a few
>> work fine. I did a tutorial for the event, showing how to use
>> open process to write to and read from telnet. Closing the process was a bit
>> of a hassle, but telnet itself works fine as a process.
>> If everything fails, you can write a shell script and run that from
>> AppleScript or tell the Finder to run the AppleScript app that starts the
>> shell script etc... There are quite a few workarounds available in Mac OS X.
>> --
>> Best regards,
>> Mark Schonewille
>> Economy-x-Talk Consulting and Software Engineering
>> Homepage:
>> Twitter:
>> KvK: 50277553
>> What does that error mean? Buy LiveCodeErrors for iPhone now
>> A must-have for LiveCode programmers.
>> On 23 aug 2011, at 23:01, Nonsanity wrote:
>> > As per the Dictionary (and my own testing):
>> >
>> > Note:  On OS X systems, you can use the open process command to start up
>> an
>> > application, but not a Unix process. To work with a Unix process, use
>> the
>> > shell func instead.
>> >
>> > And it's unix processes that I need to start, not apps. :(
>> >
>> > ~ Chris Innanen
>> > ~ Nonsanity
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:

More information about the Use-livecode mailing list