Applescript help with .sleep script

Discussion in 'Mac Programming' started by danb77, Oct 3, 2007.

  1. danb77 macrumors 6502

    Joined:
    Sep 4, 2007
    #1
    Hi,

    I am trying to write a .sleep script to employ with the handy SleepWatcher utility to unmount my USB disks and network disks when I send my MacBook to sleep.

    My current script is

    #!/bin/sh
    osascript -l AppleScript -e 'tell Application "Finder" to eject every disk whose ejectable is true or not local volume is true'


    The problem with this is that it does not verify that the unmount has been successful, so sometimes the computer shuts down with the drives still mounted.

    Does anyone have an idea how I can change the script to:

    Wait until the mount has been successful before finishing (and allowing SleepWatcher to shut the system down)

    If this does not occur within n seconds display an error message.

    Thanks in advice,

    Dan (the applescript newbie!)
     
  2. danb77 thread starter macrumors 6502

    Joined:
    Sep 4, 2007
    #2
    OK, so maybe this wasn't the best place to post this question. Can anyone recommend a good Applescript forum?
     
  3. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #3
    Here is a good one
     
  4. MongoTheGeek macrumors 68040

    MongoTheGeek

    Joined:
    Sep 13, 2003
    Location:
    Its not so much where you are as when you are.
    #4
    try this.

    #!/bin/sh
    umount -f /volumes/*

    It will fail on the system disk unless you are running as root but will unmount everything else.

    As for a place to ask scripting questions there is the MACSCPT listserv run out of Dartmouth. Volume has dropped off tremendously but there are a lot of people there with a lot of knowledge in different scripting languages.
     
  5. danb77 thread starter macrumors 6502

    Joined:
    Sep 4, 2007
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    This site seems to be fairly active.
     

Share This Page