2013-05-19 5 views
0

~/Library/Logs/DiagnosticReports의 각 사용자 프로필에서 크래시 로그를 보려면 applescript를 만들려고합니다. * .crash .spin .hang 파일이있을 수 있으므로 * 끝에 *를 사용합니다. 현재 바탕 화면에 "Test"라는 폴더에 모두 복사하되 알맞지 않은 방법인지 확인하십시오.파일이 applescript가있는 다른 프로필에있는 경우 어떻게보고 복사합니까?

내가 노력하고 내가

오류 TEST.TXT \ "\를 만들 수 없습니다"얻을 실행 "타입의 정수로." "TEST.TXT"에서 숫자 -1700 모든 도와

try 
    do shell script "ls /users >$HOME/Desktop/Users.txt" 
    do shell script "mkdir ~/Desktop/Test" 
end try 

set b to boot volume of (system info) 
set u to b & "Users" 

set theFiles to paragraphs of "Test.txt" 



repeat theFiles times 
duplicate file u & theFiles & "~/Library/Logs/DiagnosticReports/Xxxxx*" to "~/Desktop/Test" 

end repeat 

감사를 정수로.

do shell script "mkdir -p ~/Desktop/Test 
cp /Users/*/Library/Logs/DiagnosticReports/* ~/Desktop/Test" with administrator privileges 

또는 루프 folders of (path to users folder)을 통해 :

답변

1

그냥 쉘 스크립트를 수행 사용하는 다른 사용자의 파일을 읽을 수있는 권한이없는 경우

tell application "Finder" 
    if exists folder "Test" of desktop then 
     set d to folder "Test" of desktop 
    else 
     set d to make new folder at desktop with properties {name:"Test"} 
    end if 
    repeat with f in (get folders of (path to users folder)) 
     tell contents of f 
      if exists folder "DiagnosticReports" of folder "Logs" of folder "Library" then 
       duplicate items of folder "DiagnosticReports" of folder "Logs" of folder "Library" to d 
      end if 
     end tell 
    end repeat 
end tell 

을 루트로 찾기를 실행할 수 있습니다 launchctl unload /System/Library/LaunchAgents/com.apple.Finder.plist; sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder.

+0

고마워요.하지만 두 스크립트 모두 현재 사용자의 로그 만받는 것처럼 보입니다. 테스트를 위해 다른 사용자에게 충돌 로그를 저장하고 복사하지 않았습니다. – Breathable

+0

루트 권한이 필요한 경우 관리자 권한으로 추가하거나 Finder를 루트로 실행하십시오. – user495470

+0

죄송하지만 어떻게 설정 하시겠습니까? – Breathable