----------------------------
-- returning a string
----------------------------
set mounted to do shell script "test -d /Volumes/username && echo yes || echo no"
if mounted = "yes" then
display dialog "Is mounted." buttons {"Ok"} default button 1
else
display dialog "Not mounted." buttons {"Ok"} default button 1
end if
----------------------------
-- capturing the exit status
----------------------------
set not_mounted to 0
try
do shell script "test -d /Volumes/username"
on error number errorNumber
set not_mounted to errorNumber
end try
if not_mounted > 0 then
display dialog "Not mounted." buttons {"Ok"} default button 1
else
display dialog "Is mounted." buttons {"Ok"} default button 1
end if
----------------------------
-- using a boolean
----------------------------
set mounted to true
try
do shell script "test -d /Volumes/username"
on error
set mounted to false
end try
if mounted then
display dialog "Is mounted." buttons {"Ok"} default button 1
else
display dialog "Not mounted." buttons {"Ok"} default button 1
end if
open check-volume-mounted in the applescript editor