« [trashItemAtURL]フォルダの中身をゴミ箱に入れる | トップページ | [bundleIdentifier]UTIを取得する »

[NSTask]シェルコマンドの実行

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application
property refNSString : a reference to refMe's NSString




set strAppName to "Dock" as text
set strCommandText to ("/usr/bin/killall \"" & strAppName & "\"")
set ocidAppName to refNSString's stringWithString:strCommandText
set ocidTermTask to refMe's NSTask's alloc()'s init()
ocidTermTask's setLaunchPath:"/bin/zsh"
ocidTermTask's setArguments:({"-c", ocidAppName})
set listDoneReturn to ocidTermTask's launchAndReturnError:(reference)
if (item 2 of listDoneReturn) is not (missing value) then
log "エラーコード:" & (item 2 of listDoneReturn)'s code() as text
log "エラードメイン:" & (item 2 of listDoneReturn)'s domain() as text
log "Description:" & (item 2 of listDoneReturn)'s localizedDescription() as text
log "FailureReason:" & (item 2 of listDoneReturn)'s localizedFailureReason() as text
end if

|

« [trashItemAtURL]フォルダの中身をゴミ箱に入れる | トップページ | [bundleIdentifier]UTIを取得する »

NSTask」カテゴリの記事