why won't applescript record?
iMac Snow Leopard
I open applescript, hit record - open disk utility - mount a drive - tell applecript to stop
Nothing shows in the applescript window. What am I doing wrong?
Thanks
iMac Snow Leopard
I open applescript, hit record - open disk utility - mount a drive - tell applecript to stop
Nothing shows in the applescript window. What am I doing wrong?
Thanks
See AppleScript Editor->Help->AppleScript Editor Help->search for record and look at recording scripts; wherein, you'll find that Disk Utility isn't scriptable.
27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10.1), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2
This was the script that I was using: do shell script "diskutil mount /dev/disk1s10" that I recorded a few years ago.
When I found it gave an error that it couldn't find the disk I tried recording it again when I found out that it wouldn't record.
I got info from diskutil which told me that the disk was disk1s2, not 10.
I edited the original script that gave the error correcting the disk name, saved the app, and it works fine now.
I don't know why the editor stopped working with disutil ( os update?) or why the disk designation changed but it works now.
Curious. Thanks for your interest.
/dev/diskNsX is a 'device node' as such it depends on the order that disks get connected.
N is the disk number, X is the session number (partition). It's not a good idea to rely on these, sometimes a disk can be slow & they get mounted in a different order - other identifiers are more stable…
diskutil mountdisk NAME-OF-DISK
or
diskutil mount [UUID]
[UUID] is a unique identifier that can be found in Disk Utility app, select the volume & use the info button to view the volume details…
…
Universal Unique Identifier: 12358BA8-0BA0-355E-810D-97BCDB1F3AD3
The diskutil command will also show it via the info keyword
diskutil info NAME-OF-DISK
…
Volume UUID: 12358BA8-0BA0-355E-810D-97BCDB1F3AD3
Pick the name or the UUID, the UUID should remain constant until you reformat, so consider that the best option.
As ever the manual helps… (see the DEVICES section near the bottom for identifier info).
Or…
man diskutil in Terminal
P.S. Read the 10.6 manual - it's possible some identifiers are new features.
Here is one approach. Presents you with a selectable list of the partition names that it detects. It then tests to see if the partition is already mounted, and if not it mounts it and then informs you. Otherwise, it will tell you that it is already mounted.
-- build a list of Apple_HFS and FAT 32 mountable disks that are available
set mountList to {}
-- we can mount Apple_HFS, or FAT 32 filesystems
set mygrepTypes to "| egrep 'Apple_HFS|DOS_FAT_32' "
-- diskutil info places the partition name in these columns
set mycut to "| cut -c 34-52 "
-- trim all trailing spaces after partition names
set mysed to "| sed 's/[ ]*$//'"
-- return each mountable partition name into the list
set mountList to paragraphs of (do shell script "diskutil list " & mygrepTypes & mycut & mysed & "&")
set myPartition to (choose from listmountListwith title ¬
"Mountable Partitions List" with prompt "Please select partition to mount")
-- if the cancel button is clicked
if myPartition is false then quit
-- is the partition mounted or not
-- returns Yes or No strings
set status to (do shell script "diskutil info " & quoted form of (myPartition as text) & " | awk '/Mounted:/ {print $2}' &")
if status is "Yes" then
display dialog "Sorry, the partition " & quoted form of (myPartition as text) & " is already mounted"
else
display dialog (do shell script "diskutil mount " & quoted form of (myPartition as text))
end if
AFAIK, you never recorded it, since DU isn't scriptable, that's why you need to use the do shell script command, but most likely got the command from somewhere else. Glad you got it working.
You're so generous with your reply - more information than I can absorb :-)
Many thanks.
I think you hit the nail. I probably did find the text.
I appreciate the wonderful help I've received here.
Thanks for the information. What a great group!
why won't applescript record?