• 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: AppleScript. launch executable without waiting for it to terminate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript. launch executable without waiting for it to terminate


  • Subject: Re: AppleScript. launch executable without waiting for it to terminate
  • From: Andrew Oliver <email@hidden>
  • Date: Fri, 19 Jan 2007 18:50:31 -0800


On Jan 19, 2007, at 6:26 PM, Alex Sheh wrote:

Hi all,
I would like to write an AppleScript that launches an executable in the background, and then returns immediately.  Currently I have the following,
 
do shell script “/Path/To/myExecutable” &
(NOTE: myExecutable runs indefinitely waiting for input)
 
However, even though I specify an ampersand to launch myExecutable in the background, my AppleScript hangs waiting for myExecutable to terminate.  Is there a way to achieve the described behavior (my AppleScript returns immediately)?
 

Specifying an & (inside the quotes) is not sufficient.

While that backgrounds the task, AppleScript still holds onto the process' stdout and stderr to catch the output of the command. To regain control back in your script you need to suppress (or redirect) these:

do shell script "/path/to/myexecutable > /dev/null 2>&1 &"

The > /dev/nul suppresses stdout (sends it to /dev/null, but it could be a file), and 2>&1 sends stderr to the same place as stdout.

Andrew
:)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • RE: AppleScript. launch executable without waiting for it to terminate
      • From: "Alex Sheh" <email@hidden>
References: 
 >AppleScript. launch executable without waiting for it to terminate (From: "Alex Sheh" <email@hidden>)

  • Prev by Date: RE: AppleScript. launch executable without waiting for it toterminate
  • Next by Date: Re: AppleScript. launch executable without waiting for it toterminate
  • Previous by thread: Re: AppleScript. launch executable without waiting for it toterminate
  • Next by thread: RE: AppleScript. launch executable without waiting for it to terminate
  • Index(es):
    • Date
    • Thread