Hi I have a nice little applescript app that among other things fires off a couple of do shell scripts. While these scripts are running I’d like some sort of feed back (probably a progress bar or something)
I thought of feeding the script out put to a file and getting apple script to read this but it still doesn’t get around the problem that because the scripts run one after another and sometimes these take time that feed back is not consistent and can give the appearance that the application has locked up.
From what I can tell, each shell command is different, and spits out it’s own results (or nothing :(). I would think that tracking multiple shell commands’ results might get a bit difficult, not to mention involve a lot of code. I may be wrong, so hopefully some of the more experienced guys have a good method they could share.
Perhaps you could pop open a small window with a progress bar (make sure it’s ‘indeterminate’) and just set it to spin until all of your code is done. That way the user knows SOMETHING is happening… and you won’t have the overhead of trying to create a scripting nightmare evaluating the status of all your shell commands. You could also set a text field value so the user knows which step the app is at…
tell progress indicator "currentStatusBar" of window "window" to start
set contents of text field "currentStatus" to "Processing Shell Command One..."
set shellResultOne to do shell script theFirstScript
set contents of text field "currentStatus" to "Processing Shell Command Two..."
set shellResultTwo to do shell script theSecondScript
set contents of text field "currentStatus" to "Processing Shell Command Three..."
set shellResultThree to do shell script theThirdScript
set contents of text field "currentStatus" to "All Shell Commands Executed!"
tell progress indicator "currentStatusBar" of window "window" to stop
Obviously you’ll want lots of error handling and extra stuff in here, but this is the basic premise. I am using curl in an app and am having trouble reading it’s built-in status meter and mimicking it’s value in my app. If I find a way, I’ll certainly post it here and anyone who’s willing to fill in this gap it welcome to do so.
Hope this helps, and thanks for any input about curl…
j
In one project I had recently, I used the method jobu demonstrated, except I used a handler to slightly clean up the code (personal preference).
on something()
my setStatus("Doing something.")
--do something
my setStatus("Finished doing something")
end something
on setStatus(theStatus)
set contents of text field "status" of window "main" to theStatus
end setStatus