2012-09-06 3 views
0

MAC에 설치된 응용 프로그램을 얻으려면 AppleScript에서 terrminal 명령 행 "system_profiler SPApplicationsDataType"을 실행했습니다. 출력을 구문 분석해야합니다. Pls는 Apple 스크립트 나 Python을 통해이를 수행하는 방법을 설명합니다.AppleScript에서 터미널 명령 실행

+0

유용한 답변을 찾았습니까? 질문에 대한 답변을 수락하지 않았습니다. 당신은 SO에게 다시 기여하는 법을 배워야합니다. –

답변

0

파이썬에서 당신은 하위 프로세스 사용할 수 있습니다 - 특히

http://docs.python.org/library/subprocess.html

check_output 방법 : http://docs.python.org/library/subprocess.html#subprocess.check_output

그래서 그냥 사용합니다 :

output = subprocess.check_output(["system_profiler", "SPApplicationsDataType"]) 
print output # or do something else with it 

귀하의 명령이있을 것 배열로 나뉘어 진 각 argu에 대한 하나의 요소 멘토. 명령을 실행하고 텍스트 편집기로 출력을 덤프

set textReturned to (do shell script "system_profiler SPApplicationsDataType") 

tell application "TextEdit" 
    activate 
    make new document at the front 
    set the text of the front document to textReturned 
end tell 

이 :

경우 애플 당신이 뭔가를 할 수 있습니다.

+0

답장을 보내 주셔서 감사합니다. AppleScript 또는 Python을 사용하여 다운로드 한 응용 프로그램을 설치하는 과정을 자동화하는 방법에 대한 아이디어가 있습니까 ?? 그렇다면 pls가 나를 제안합니다. – user1648855

+0

그것에 대해 좀 더 연구해야 할 것입니다. :) (또한, 답변이 맞다면 올바른 것으로 받아들이십시오!) –

관련 문제