3

I'm new to Terminal, so feel free to state the obvious.

SleepWatcher runs scripts right before and after your Mac goes to sleep. I've got a script to unmount an external disk before sleep, then remount it after. (That way, when I'm rushing to get to work in the morning, I can just close the lid, pull out all the cables and not get a "You didn't eject it, jerk!" complaint.)

The scripts run fine and it unmounts right before sleep. But, it won't remount after wake.

#!/bin/sh

diskutil mount 8851F3A7-60A7-39A7-9DA8-41BE1499DE6C 

I can run this script manually in Terminal. It'll work then. SleepWatcher can execute the script (I can get it to display a dialog box), just not the command to mount.

What am I missing?

Update: I've chmod-ed the scripts as +x. Can diskutil be run as +x?

1
  • I didn't get /usr/sbin/diskutil mountDisk to work in the normal crontab (either directly or in a script), but it did work when run from the root's crontab or a per-user launchd job.
    – Lri
    Jul 31, 2012 at 13:34

3 Answers 3

1

It's quite possible the device isn't available when SleepWatcher runs it's script. You can try running diskutil list > /PATH/TO/SOME/FILE in the script to see what diskutil sees at the time the script is actually run. You may need to introduce a delay (eg. sleep 5) on the script while you wait for the drive to become available to actually mount.

5
  • Just tried that (18 seconds), and still no dice. How can I log what the script is doing?
    – bushytop
    Aug 12, 2009 at 7:54
  • Getting the script to run diskutil list results in log files that are empty. It doesn't even list the internal disks. (Running the command manually produces a proper log file.) Huh.
    – bushytop
    Aug 12, 2009 at 8:15
  • If you run diskutil >> /PATH/TO/SOME/FILE just to get output and see that diskutil will even run or if it's some other issue.
    – Chealion
    Aug 12, 2009 at 16:34
  • @Chealion, If it's run with SleepWatcher, I just get blank files. If I run them manually, I get proper outputs. So, for some reason, diskutil won't run automated. Is there any other way I can mount an external disk with Terminal (or AppleScript)?
    – bushytop
    Aug 13, 2009 at 7:14
  • 1
    Odd question, are you using just diskutil or the full path usr/sbin/diskutil? If you're not using the full path try that in the script.
    – Chealion
    Aug 13, 2009 at 14:42
0

Try /usr/sbin/diskutil in the script. Depending on how the application executes the script, this could make all the difference.

0

Try mounting the disk itself, rather then a single volume (even if it's the only volume on the disk).

For your .wakeup script, replace

 diskutil mount 8851F3A7-60A7-39A7-9DA8-41BE1499DE6C

with:

 diskutil mountDisk disk1s3

... replacing 'disk1s3' with the proper device identifier for your own external disk, of course. I don't think I need to tell someone who is capable of specifying a volume by its UUID where to find that information. For everyone else, here's how:

 diskutil list

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .