• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Volume status
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Volume status


  • Subject: Re: Volume status
  • From: Graff <email@hidden>
  • Date: Sat, 02 Oct 2004 17:42:15 -0400

Hmm, I didn't know that you could just use the mount point for the drive, I thought you needed its device number for "diskutil info" so this simplifies my script a bit:

----
on IsDiskReadOnly(theName)
set searchString to quoted form of ("/Volumes/" & theName)

set theResult to do shell script "diskutil info " & searchString & " | awk '/Read Only:/{ print $3 }'"

if (theResult contains "Yes") then
return true
else
return false
end if

end IsDiskReadOnly


tell application "Finder"
	my IsDiskReadOnly(name of disk 1)
end tell

--> false
-- false because disk 1 is my startup hard drive
----

If you are going to use the shell you should use the "quoted form of" command instead of manually putting in quotes yourself. What if the volume name had quotes as part of its name? Then your manually-quoted string would get messed up and the script would have an error. In some cases an error like that can cause a loss of data, like if you were using the "rm" shell command. The "quoted form of" command takes care of these problems.

- Ken

On Oct 2, 2004, at 3:48 PM, Jakub Formanek wrote:

Thanks everyone who have sent me tips and sample code!
For your information; my unix guru friend sent me a Shell example.

Below is my AppleScript source code:
------
copy "/Volumes/theVolume" to theVolume

if (my writableVolume(theVolume)) then log "This volume is writable."

on writableVolume(theVolume)
try
do shell script "diskutil info " & "\"" & theVolume & "\"" & " |
grep -q \"Read Only: No\""
return true
on error
return false
end try
end writableVolume
------

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Volume status (From: Jakub Formanek <email@hidden>)

  • Prev by Date: Re: Gibberish lesson
  • Next by Date: Re: Gibberish lesson
  • Previous by thread: Re: Volume status
  • Next by thread: Re: Subject: Scripting QuarkXPress Books
  • Index(es):
    • Date
    • Thread