Use AppleScript to synchronize Entourage mail

Jul 23, '04 11:23:00AM

Contributed by: JazzDude

I use Entourage as my eMail client. As I take my PowerBook with me to work almost every day I need to

With a little help from the kind folks in the macosxhints forums, I wrote a script that does all that with a single click.

tell application "Microsoft Entourage"
  quit
end tell

do shell script ¬
  "ssh powerbook killall \\'Microsoft Database Daemon\\'"

do shell script ¬
  "ssh powerbook exit"

mount volume "afp://powerbook/PowerBookHD" as user name ¬
  "jazz" with password "password"

-- NOTE: The rm -rf line is shown on two lines. Enter it as *ONE LINE* --
do shell script ¬
  "rm -rf /Volumes/PowerBookHD/Users/jazz/Documents/'Microsoft User Data'/
   'Office 2004 Identities'"

-- NOTE: The ditto line is shown on three lines. Enter it as --
--       one line (leave a space before /Volumes)            --
with timeout of 180 seconds
    do shell script ¬
   "ditto -rsrc ~/Documents/'Microsoft User Data'/'Office 2004 Identities' 
    /Volumes/PowerBookHD/Users/jazz/Documents/
    'Microsoft User Data'/'Office 2004 Identities'"
end timeout

tell application "Finder"
  eject "PowerBookHD"
end tell
Now, to send a terminal command to another machine you need to have "Remote Login" enabled on that machine so you can get a remote shell (via ssh). In order to issue commands without having to type a password, you need to authenticate your machine before. I had a snippet of an older hint (or comment) lying around describing the process (I couldn't find the original hint here):
On the machine you are SSHing from (source machine), generate a private key:
ssh-keygen -b 1024 -t dsa   
If you use the default values for all the promps, you should now have ~/.ssh/id_dsa.pub and ~/.ssh/id_dsa files. Copy the contents of the .pub file to your clipboard or somewhere. The contents should be one long line that looks something like:
ssh-dss AAAAB3NzaD1 ... aXdf9L4D== user@machine.local   
Connect to the machine you want to ssh to (destination machine) the old way, using your password. Now, paste the contents of the .pub file from the souce machine to the end of ~/.ssh/authorized_keys file on the destination machine. Make sure it's all one line. That's it. You should now be able to ssh from one machine to the other without entering a password. If you want to ssh to another machine, you don't need to rerun ssh-keygen. Just use the same id_dsa.pub file again.
Of course, I wrote a similar script for the PowerBook that copies the Office folder back to the iMac when I return home.

[robg adds: this older hint also covers creating password-free SSH logins.]

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040720055359248