Skip navigation

Mount/unmount 2nd internal drive (mount working)

1005 Views 6 Replies Latest reply: Jun 7, 2012 12:53 PM by mavric1298 RSS
mavric1298 Level 1 Level 1 (0 points)
Currently Being Moderated
May 22, 2012 1:37 PM

So I can't seem to figure out whats wrong with my script, any help would be greatly appreciated;

 

So when I run it, it will mount the drive if it is unmounted, but it won't unmount the drive when run

 

set diskName to "OptiBay"

tell application "Finder"

          if disk diskName exists then

  eject disk diskName

          else

                    tell current application

                              set deviceLine to (do shell script "diskutil list | grep \"" & diskName & "\" | awk '{ print $NF }' ")

                              if deviceLine = "" then

                                        display dialog "The disk \"" & diskName & "\" cannot be found." buttons {"OK"} default button 1 with title "Error" with icon caution

                              end if

                              set foundDisks to paragraphs of deviceLine

                              repeat with i from 1 to number of items in foundDisks

                                        set this_item to item i of foundDisks

                                        if this_item contains "disk" then

                                                  do shell script "diskutil mountDisk /dev/" & this_item

                                        end if

                              end repeat

                    end tell

          end if

end tell

MacBook Pro (15-inch Core 2 Duo), Mac OS X (10.7.3)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.