• 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: Delaying a script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delaying a script


  • Subject: Re: Delaying a script
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 18 Jan 2005 15:08:25 -0800

On Jan 18, 2005, at 10:46 AM, Klaas.Lists wrote:

  My script is using a DO SHELL SCRIPT  action,
  which returns a result (via the Clipboard).

  It would not work, DISPLAY DIALOG result would
  not show the correct value, until I realised
  that my script would continue running, not
  waiting for the DO SHELL SCRIPT to finish.

  What I would like to know: What is the accepted
  way to wait in AppleScript, without a busy loop?

Well, you could use the "delay" command, but that just takes a number of seconds to wait -- there's no command to wait for a condition. You can get away without an actual loop in some cases by using an "on idle" handler, which gets called periodically if your script is saved as an application.


However, the fact that you're having this problem in the first place is sort of weird -- usually people have the reverse problem; they want "do shell script" to *not* stop execution of their script. A few things to consider:

1. Did you deliberately background the process using "&"? If so, stop doing that.

2. If the command is somehow detaching itself, does it have an option to not do that?

3. Why use the clipboard? If the shell command has output, it will be returned as the result of the "do shell script" command. For example:

    set x to do shell script "echo foo"
    x --> "foo"

You may find <http://developer.apple.com/technotes/tn2002/tn2065.html> helpful.


--Chris Nebel AppleScript Engineering

_______________________________________________
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: Delaying a script
      • From: "Klaas.Lists" <email@hidden>
References: 
 >Delaying a script (From: "Klaas.Lists" <email@hidden>)

  • Prev by Date: Re: OT: preserving long links in email
  • Next by Date: Re: META: preserving long links in email
  • Previous by thread: Delaying a script
  • Next by thread: Re: Delaying a script
  • Index(es):
    • Date
    • Thread