태그 보관물: plist

plist

launchctl을 사용하여 AppleScript 스크립트를 주기적으로 실행하십시오. 실행하고 싶습니다. 그래서 나는

특정 파일을 백업 할 수있는 AppleScript를 작성했습니다. 스크립트는 AppleScript 편집기에서 제대로 실행됩니다. 완벽하게 수행되는 작업을 수행합니다. 여태까지는 그런대로 잘됐다.

이제이 스크립트를 정기적으로 실행하고 싶습니다. 그래서 나는 이것을 시작하기 위해 launchctl & .plist를 사용합니다. 그곳에서 문제가 시작됩니다.

  • launchctl에 의해 설정된 간격으로 스크립트가로드됩니다.
  • AppleScript 편집기 (열린 경우)는 해당 스크립트가있는 창을 전경으로 가져 오지만 코드는 실행되지 않습니다.
  • AppleScript Editor가 실행 중이 아니면 아무 일도 일어나지 않는 것 같습니다

왜 이것이 작동하지 않는지에 대한 아이디어가 있습니까?

Daniel Beck의 제안에 따라 편집 후 내 plist는 다음과 같습니다.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.opera.autosave</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/user_name/Library/Scripts/opera_autosave_bak.scpt</string>
</array>
<key>StartInterval</key>
<integer>30</integer>
</dict>
</plist>

그리고 내가 실행하려고하는 AppleScript :

on appIsRunning(appName)
    tell application "System Events" to (name of processes) contains appName
end appIsRunning

--only run this script when Opera is running
if appIsRunning("Opera") then
    set base_path to "user_name:Library:Preferences:Opera Preferences:sessions:"
    set autosave_file to "test.txt"
    set autosave_file_old to "test_old.txt"
    set autosave_file_older to "test_older.txt"
    set autosave_file_oldest to "test_oldest.txt"
    set autosave_path to base_path & autosave_file
    set autosave_path_old to base_path & autosave_file_old
    set autosave_path_older to base_path & autosave_file_older
    set autosave_path_oldest to base_path & autosave_file_oldest
    set copied_file to "test copy.txt"
    set copied_path to base_path & copied_file

    tell application "Finder"
        duplicate file autosave_path
        delete file autosave_path_oldest
        set name of file autosave_path_older to autosave_file_oldest
        set name of file autosave_path_old to autosave_file_older
        set name of file copied_path to autosave_file_old
    end tell

end if


답변

애플 스크립트 편집기에서 응용 프로그램으로 스크립트 저장 ( 파일»다른 이름으로 저장 … ), 또는 launchd에의 호출 변경 plistosascript인수로 스크립트 파일 (애플 스크립트를 실행하는 터미널 방법).


답변

이것의 영향을받는 것 같습니다 :

따라서 AppleScript 편집기, Automator 내, 독립형 앱 또는 액적 등 스크립트를 “수동으로”실행하면 스크립트를 사용하여 현재 수행 할 수있는 모든 작업을 수행 할 수 있습니다. 다시 말해, 항상 그렇듯이 손으로 스크립트를 계속 실행할 수 있어야합니다.

내부 응용 프로그램 스크립트 : 일부 응용 프로그램은“내부”AppleScript를 사용하여 특정 작업을 처리합니다. 예를 들어 BBEdit ()는 명령 줄 도구를 설치할 때 이러한 스크립트를 사용합니다. 이러한 스크립트는 앱에 내장되어 있습니다. 메뉴 나 다른 곳에서는 볼 수 없습니다. 이러한 자체 참조 스크립트는 항상 그렇듯이 계속 작동해야합니다.

그러나 샌드 박스 응용 프로그램이 AppleScript를 사용하여 다른 응용 프로그램이나 시스템의 다른 부분 (예 : AppleScript를 사용하여 iTunes를 제어하는 ​​메뉴 표시 줄 응용 프로그램)과 상호 작용하려는 경우 새로운 제한이 적용됩니다. 샌드 박스 응용 프로그램은 AppleScript를 사용하여 Mac에서 다른 응용 프로그램과 통신 할 수 없습니다. 개발자가 해당 작업을 수행 할 수있는 권한을 구체적으로 요청 (수신)하지 않는 한.

http://www.macworld.com/article/1165641/how_increased_mac_security_measures_will_impact_applescript.html


답변