管理者権限があるかどうか確認する
ルーチンの確認にスクリプトエディタで作ったコード。Studioではそのままだと動かないけど。
do shell script "id -G" -- GIDの一覧を得る
set StatusData to result -- "502 79 80 81"
set begin_delimi to text item delimiters of AppleScript -- 初期値を保存 後で戻す必要あり
set text item delimiters of AppleScript to " "><
set StatusList to text items of StatusData -- spaceで分割してリストに変換
><
set text item delimiters of AppleScript to begin_delimi -- デリミタを復帰
set theFlag to ""
repeat with thisData in StatusList><
set thisData to thisData as string
if thisData is "80" then><
set theFlag to "admin"
><
exit repeat
else
set theFlag to "user"
end if><
end repeat
><
if not theFlag is "admin" then
display dialog "現在のユーザーは「管理者」権限がありません。管理者権限のあるユーザーでログインしてご利用下さい。" with icon stop buttons {"OK"} default button 1
if result is "OK" then
quit
end if
end if