3

I'm working on a simple AppleScript that runs the following...

do shell script "diskutil partitionDisk /dev/disk1 1 APM JHFS+ Test 1G"

It's part of a bigger script. The above works fine but is there a way of viewing the progress? Anything will do really, preferably the actual command within a terminal window would be good.

Thanks

2 Answers 2

3

I often have the need for seeing the progress of do shell script commands and other various stages of an AppleScript script while it is running. What I do for do shell script is log the output to a log file and then use a program called MKConsole to display it on the Desktop. For example:

do shell script "diskutil verifyPermissions // &> /output.log"

In the above command diskutil will start up and start running and log standard output to the log file I created called output.log located at /. It won't show you the 0%...10%...20% progress indicator that you see in the Terminal but it does show you all the other output.

Then I configure MKConsole's preferences to read this log file and then in real time it will display all new log messages from that file on my Desktop.

If you need progress of non-shell script commands and need to log AppleScript activity then you can use the logger command. For example:

do shell script "logger -f /output.log The current count is: " & some_variable

If you have an AppleScript which runs for a long time and uses repeat loops and you'd like to know what stage of completion the script is in while running then the above logger command is a great method for getting some feedback on the progress. I usually throw in a logger command right at the bottom of the script above the end repeat so that it is the last thing it does in that iteration of the loop.

The logger command method works well with MKConsole as well so that you can see the output in real time on your Desktop.

Sign up to request clarification or add additional context in comments.

Comments

1

Invoke a terminal and have the terminal run diskutil:

"xterm -e 'diskutil partitionDisk /dev/disk1 1 APM JHFS+ Test 1G'" is the commandline to pass to the shell, and have xterm(1) display the diskutil output. Other terminals(than xterm) can be used, and the window size font, and colors can be controlled: see the manual page for the terminal.

Maybe another way to show progress would be to run the entire script(not just the diskutil part) in a window.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.