Droplet to Unmount dragged-on Volume
Droplet to Unmount dragged-on Volume
- Subject: Droplet to Unmount dragged-on Volume
- From: Marconi <email@hidden>
- Date: Mon, 09 May 2011 07:11:59 -0700
I have created a droplet app bundle to (among other things) unmount
the dragged-on volume. It doesn't work though, reporting that
unmounting is not permitted. Doubtless this is due to being in use by
the AS droplet itself. Once the script is done running, I can unmount
the volume by normal means.
Now, you are probably wondering why I need a droplet to unmount a volume...
The app bundle contains a binary file dd'd from a disk that had been
erased using the Write Zeroes option. It is 100 sectors (or blocks)
of erased disk. It is my intention to dd this 100-sector file to the
start of the disk containing the dropped-upon volume, thus wiping out
its partition map and rendering it like it came from the factory. I
precede this partition map wipe with an erase operation, writing
zeroes using disk utility. (Once I get the partition map wiping
figured out, I'll probably incorporate the erase with zeroes into the
droplet as well.)
Anyway, it would appear that my droplet script is making the dropped
volume busy and thus making unmounting impossible. I've commented out
the line that would actually do the dd operation to render this
droplet impotent.
I'm certain that the code below could be streamlined if I were more
knowledgeable.
If anyone can tell me how to get the unmount to work, I'd much appreciate it.
-- If double clicked, open in editor
tell application "Script Editor"
activate
open (path to me)
end tell
return
--set the_Data to "" -- what we'll display at the end of the run
on open dropList
set AllZeroes to POSIX path of (path to me) & "Contents/Resources/ZeroDisk.bin"
if (count items of dropList) > 1 then
beep
delay 1
return
end if
set diskAlias to (item 1 of dropList) as alias
tell application "Finder"
if (class of item diskAlias) is not disk then
display dialog "That is not a disk." buttons {"OK"} default button 1
return
end if
end tell
set Vol_Name to POSIX path of diskAlias
set the_Data to "Info for " & Vol_Name & {return} & {return}
set command to "diskutil info " & Vol_Name
set Vol_Info to (do shell script command)
set device_Name to "/dev/r" & extract("Part of Whole:", Vol_Info)
display dialog "You are about to totally wipe the volume " &
Vol_Name buttons {"OK", "Cancel"} default button 2
set commandLine to "umount " & Vol_Name
set The_Result to do shell script commandLine
display dialog The_Result
set commandLine to "dd if=" & AllZeroes & " of=" & device_Name
display dialog commandLine
-- set The_Result to do shell script commandLine
display dialog The_Result
end open
-- Note: This script makes calls to run the shell command 'diskutil info...'
-- The info returned by 'diskutil info...' is padded with spaces to make the
-- columns align. 'extract finds the parameter value and strips leading spaces.
-- There are doubtless more efficient ways to do this...
on extract(param, structure)
set foo to offset of param in structure
set startpoint to (foo + (length of param))
set endpoint to length of structure
set tempdata to text startpoint through endpoint of structure
-- we've selected from the parameter name to the end of the record.
set AppleScript's text item delimiters to {return}
set temp_Result to text item 1 of tempdata
-- we've selected selected from the parameter name to the first
return encountered.
set AppleScript's text item delimiters to ""
-- Now strip leading spaces from the value.
repeat while (first item of temp_Result = space)
set temp_Result to items 2 thru -1 of temp_Result
end repeat
return temp_Result
end extract
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden