Show results from Terminal in AppleScript

Hi! I’ve cobbled together my first AppleScript, shown below, which syncs my iTunes library to another machine. It works great, only you don’t really know it’s running unless I run it from Script Editor. Is there anyway to show the current verbose output from rsync?

Here’s my script, with parts edited for security :slight_smile:

display dialog "Copy iTunes Library from:" buttons {"Cancel", "MacBook Pro", "Mac Mini"} default button 1
copy the result as list to {buttonpressed}
if the buttonpressed is "MacBook Pro" then
	try
		mount volume "afp://[myserver]/[share]"
		do shell script "rsync -av --force --delete [my source] [my destination]"
		do shell script "umount /Volumes/[share]"
	end try
else if the buttonpressed is "Mac Mini" then
	try
		mount volume "afp://[myserver]/[share]"
		do shell script "rsync -av --force --delete [my source] [my destination]"
		do shell script "umount /Volumes/[share]"
	end try
end if
display dialog "Copy complete" buttons {"OK"} default button 1

If any of my scripting is bad practice, please let me know as I’m keen to learn. I appreciate any help given :slight_smile:

Hi squareforg,

Unfortunately you won’t be able to display the intermediate output of your «do shell script» commands as it is created. You can only get back the complete output at once at the time a «do shell script» command is finished:


set output to do shell script "mdfind -onlyin ~/Library/Preferences/ plist" 

When entering the above «mdfind» command in a Terminal window, you can really watch how the files are more or less quickly listed. With the «do shell script» command, you just get the whole result back at once after it was executed.

This is also the reason why it is difficult to build a progress bar for such situations. So maybe you should consider to script the Terminal app in order to be able to see the intermediate results. That would be my idea.

OK well thats no big disappointment. Now I have my terminal set to use the Homebrew theme, I like having it open. I’ll dig around this forum and see if I can find appropriate scripting for opening terminal, running my rsync, then closing it.

The main advantage of this solution is that I don’t have to display a dialog when the script finishes if I don’t want to. Thanks for your help Martin.