Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:08:43+00:00 2026-06-03T17:08:43+00:00

I’ve got ASObjC Runner code in my AppleScript that shows a progress window once

  • 0

I’ve got ASObjC Runner code in my AppleScript that shows a progress window once a do shell script is run. How do I make the button on the progress window kill the shell script?

Heres a sampling of my code:

tell application "ASObjC Runner"
    reset progress
    set properties of progress window to {button title:"Abort", button visible:true, indeterminate:true}
    activate
    show progress
end tell

set shellOut to do shell script "blahblahblah"
display dialog shellOut

tell application "ASObjC Runner" to hide progress
tell application "ASObjC Runner" to quit
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:08:44+00:00Added an answer on June 3, 2026 at 5:08 pm

    There are several parts to the answer:

    1. Asynchronous do shell script: normally, do shell script only returns after the shell command has completed, which means you cannot act on the processes inside the shell. However, you can get a do shell script command to execute asynchronously by backgrounding the shell command it executes, i.e.

      do shell script "some_command &> /target/output &"
      

      – which will return immediately after launching the shell command. As it will not return the command’s output, you have to catch that yourself, for instance in a file (or redirect to /dev/null if you don’t need it). If you append echo $! to the command, do shell script will return the PID of the background process. Basically, do

      set thePID to do shell script "some_command &> /target/output & echo $!"
      

      see Apple’s Technical Note TN2065. Stopping that process is then a simple matter of doing do shell script "kill " & thePID.

    2. Hooking into ASObjC Runner’s progress dialog is just a matter of polling its button was pressed property and breaking on true:

      repeat until (button was pressed of progress window)
          delay 0.5
      end repeat
      if (button was pressed of progress window) then do shell script "kill " & thePID
      
    3. Deciding when your shell script is done to dismiss the progress dialog: that is the interesting part, as the shell command operates asynchronously. Your best bet is to shell out to ps with the PID you retrieved to check if the process is still running, i.e.

      if (do shell script "ps -o comm= -p " & thePID & "; exit 0") is ""
      

      will return true when the process is not running anymore.

    Which leaves you with the following code:

    tell application "ASObjC Runner"
        reset progress
        set properties of progress window to {button title:"Abort", button visible:true, indeterminate:true}
        activate
        show progress
    
        try -- so we can cancel the dialog display on error
            set thePID to do shell script "blahblahblah &> /file/descriptor & echo $!"
            repeat until (button was pressed of progress window)
                tell me to if (do shell script "ps -o comm= -p " & thePID & "; exit 0") is "" then exit repeat
                delay 0.5 -- higher values will make dismissing the dialog less responsive
            end repeat
            if (button was pressed of progress window) then tell me to do shell script "kill " & thePID
        end try
    
        hide progress
        quit
    end tell
    

    If you need to capture the output of your background shell command, you will have to redirect it to file and read out that file’s content when done, as noted above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.