7

Extend 스크립트 스크립트 내에서 호출해야하는 python 스크립트가 있습니다. 이 일을 할 수있는 라이브러리 함수가 있습니까? 나는 문서 및 다른 많은 온라인 자원에서 해결책을 찾는 것을 시도했다. 그러나 아무것도 나를 위해 지금까지 일하지 않았다. 어떤 도움을 주셔서 감사합니다.Extendscript에서 파이썬이나 쉘 스크립트를 호출하는 방법은 무엇입니까?

답변

3

this example을 살펴보십시오.
스크립트 파일 옆에 .term 파일을 생성하고 실행합니다.

이 세정 버전 :

main(); 
function main() { 
    var script_file = File($.fileName); // get the full path of the script 
    var script_folder = script_file.path; // get the path from that 
    var new_termfile = createTermFile("execute_something", script_folder); 
    new_termfile.execute(); // now execute the termfile 
} 
/** 
* creates a .term file 
* @param {String} term_file_name --> the name for the .term file 
* @param {Strin} path --> the path to the script file 
* @return {File}    the created termfile 
*/ 
function createTermFile(term_file_name, path) { 
/* 
http://docstore.mik.ua/orelly/unix3/mac/ch01_03.htm 
1.3.1.1. .term files 
You can launch a customized Terminal window from the command line by saving some prototypical Terminal settings to a .term file, 
then using the open command to launch the .term file (see "open" in Section 1.5.4, later in this chapter). 
You should save the .term file someplace where you can find it later, such as ~/bin or ~/Documents. 
If you save it in ~/Library/Application Support/Terminal, the .term file will show up in Terminal's File Library menu. 
To create a .term file, open a new Terminal window, and then open the Inspector (File Show Info, or -I) 
and set the desired attributes, such as window size, fonts, and colors. When the Terminal's attributes 
have been set, save the Terminal session (File Save, or -S) to a .term file (for example, ~/Documents/proto.term). 
Now, any time you want to launch a Terminal window from the command line, you can issue the following command: 
*/ 
    var termfile = new File(path + "/" + term_file_name + ".term"); 
    termfile.open("w"); 
    termfile.writeln(
     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
     "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"" + 
     "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + 
     "<plist version=\"1.0\">\n" + 
     "<dict>\n" + 
     "<key>WindowSettings</key>\n" + 
     "<array>\n" + 
     " <dict>\n" + 
     "<key>CustomTitle</key>\n" + 
     "<string>My first termfile</string>\n" + 
     "<key>ExecutionString</key>\n" + 
     "<string>python\nprint \"Hello World\"\nexit()</string>\n" + 
     "</dict>\n" + 
     "</array>\n" + 
     "</dict>\n" + 
     "</plist>\n"); 
    termfile.close(); 
    return termfile; 
}; 
4

수정 ExtendScript 파일 오브젝트가 실행() 메소드가, 이미 파비안으로 도시. .term 파일에 대해 몰랐으며 대신 .command 파일을 사용했을 것입니다. 이것은 XML이 아닌 일반 쉘 스크립트입니다.

경우 인디자인에서 실행, 당신은 애플 스크립트를 Terminal.app을 무시하고 사용할 수 있습니다

myScript = 'do shell script "diff f1 f2 > o" '; 
app.doScript(myScript, ScriptLanguage.applescriptLanguage); 
+1

이 예 .command 파일이 자세한 .term 파일보다 훨씬 시원하다! (몰랐다.) 유일한 것은 당신이 그것을 실행 가능하게 만들어야한다는 것이다. .term 파일이 바로 실행됩니다. – fabianmoronzirfas