In an AppleScript app, I'm downloading a file using curl in a "do shell script" command. The curl starts and AppleScript immediately moves into a loop displaying a Notification until the curl has finished.
The notification displays properly during the curl, when running from ScriptEditor. It stays visible on the Desktop until shortly after the curl has finished. But when running the app (i.e. opened in Finder), the Notification doesn't display at all until well after the curl has finished.
Here is a summary of the code:
set process_id to do shell script "curl -L https://www.downloads.com/latest/downloadthisfile-o /usr/local/bin/downloadthisfile &> /dev/null & echo $!" with administrator privileges
set process_name to "downloadthisfile"
send_notification(process_id, process_name)
-- Handler for sending notification to user while files are downloading
on send_notification(process_id, process_name)
repeat
do shell script "ps ax | grep " & process_id & " | grep -v grep | awk '{ print $1 }'"
if result is "" then exit repeat
display notification process_name & " is downloading. Please Wait." with title "Downloading " & downloadthisfile
delay 3
end repeat
end send_notification
Why would this work well when running from ScriptEditor but not when running the app itself ?
Garry