Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SimonBM

macrumors newbie
Original poster
Dec 12, 2011
2
0
Hello all,

I'm new to using AppleScript so please forgive me if my code is rubbish:D

I have the following script which will let me backup to and from a USB to a users home dir, I have tried mobile accounts but the syncing has been giving me some issues. I have now decided to enable local managed accounts and to let users backup a complete copy of their home dir, my AppleScript lest me do this well but I have a slight issue.

I cannot seem to find a way to output the progress of the backup in AppleScript, the backup works fine but I need to show the users for feedback so the know when the backup is finished.

Here is the script:

tell application "Finder"
if not (exists disk "BACKUP") then
display dialog "No Backup Disk Detected"
quit
end if

if exists disk "BACKUP" then
set CurrentUser to do shell script "whomami"
set question to display dialog "What would you like to sync?" buttons {"From Mac","To Mac","Cancel"} default button 3
set answer to button of returned question

if answer is equal to "From Mac" then
try
do shell script "rsync -vaE --delete --update '/Users/"& CurrentUser &"/' '/Volumes/BACKUP/Sync/ '"
end try
else
if answer is equal to "To Mac" then
try
do shell script "rsync -vaE --delete --update '/Volumes/BACKUP/Sync/' '/Users/"& CurrentUser &"/'"
end try
end if


end if

end tell

Hope someone can help!!

Thanks in advance,

Si
 
Thanks for the info in display a dialog box after the shell scripts end try that works well, now need to make sure a dialog box is open while the transfer is happening. just so the USB isnt unplugged until it says its done.

is it worth me trying to do the apple script in xcode? colleagues have suggested i learn ObjC and build the app from scratch, but it seems a lot of effort for something so simple and i dont really fancy bloating the program.

not to mention the syntax of ObjC looks extremely confusing, and wouldnt know where to begin learning.
 
is it worth me trying to do the apple script in xcode?
If you do more than a little casual scripting it is the way to fly. Starting out in AppleScript Objective c requires remarkably little ObjC knowledge, and provides a vastly improved user interface over straight Applescript. The learning curve on Xcode is a little steep, but there's a very nice ebook on ASOC to help you get started:
http://www.macosxautomation.com/applescript/apps/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.