Re: Volume status
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