gpt4 book ai didi

adobe-illustrator - File.execute() 没有执行我的脚本。如何调试这个问题?

转载 作者:行者123 更新时间:2023-12-04 07:46:21 25 4
gpt4 key购买 nike

我正在使用 ExtendScript 为 Illustrator CS6 编写脚本。在我的脚本结束时,我想使用 File.execute() 生成一个任务(第二个脚本,在 Ruby 中)。但是,它不起作用。我对如何调试问题一头雾水——我怎样才能弄清楚为什么这不起作用?

这是我的 ExtendScript 文件的结尾:

// Do a bunch of other work, then:
var rubyFile = new File(scriptFolder + 'BuildHtmlWalkthrough.rb');
alert(rubyFile.exists);
var result = rubyFile.execute();
alert(result);

rubyFile.existsresult 始终为真,表示脚本启动正常。但是脚本似乎根本没有运行。我尝试了以下诊断:

  • Ruby 脚本确实从命令行成功运行。脚本的权限是-rwxr-xr-x
  • 我在 Ruby 脚本的第一行添加了对 system("touch/blah/blah/blah") 的调用。文件不会被触及。
  • 我认为 ExtendScript 进程可能会在 Ruby 脚本运行之前终止,所以我在 rubyFile.execute() 之后添加了一个长循环。旋转 > 30 秒没有帮助。

我该怎么做才能调试或解决这个问题?

我使用的是 MacOS X v10.9.1。作为引用,这是 File.execute() 的文档:

File.execute (): Boolean

Core JavaScript Classes

Executes or opensthis file using the appropriate application, as if it had beendouble-clicked in a file browser. You can use this method to runscripts, launch applications, and so on. Returns true immediately ifthe application launch was successful.

最佳答案

它可能正在执行“使用适当的应用程序打开此文件”而不是执行,并返回 true 因为文件已成功打开(或已在其关联的应用程序中打开)。如果我有一个 python 脚本并执行

f= new File("~/Documents/misc_scripts/getpixelrgb.py");
f.execute();

,即使设置了文件的执行标志,它也会在我的脚本编辑器中打开它。

顺便说一句,我在 OSX 上

在 After Effects 中,有 system.callSystem() 来执行命令行命令,但恐怕 Illustrator 中没有它(我假设您是因为标签而为 Illustrator 执行此操作)。您使用的是 OSX 还是 Windows?有很多方法可以解决这个问题,方法是制作可执行文件 .app (OSX) 或 .exe (Win) 并使用 execute() 调用它。如果我这样做,我在 OSX 上,我会制作一个 AppleScript 应用程序,它执行“执行 shell 脚本”以进行 ruby​​ 系统调用。在 Windows 上,情况有所不同。如果您使用的是 Windows,您可能会喜欢一种解决方案:ocra,它是特定于 ruby​​ 的 ( http://ocra.rubyforge.org/ )。也许可以在 Windows 上运行调用 ruby​​ 脚本的 .bat 文件,但我不确定。

[编辑!]

对于无关的 Windows 信息(我猜是为其他人),我深表歉意。刚看到你关于在 OSX 上的说明。所以您可能想要使用 AppleScript 解决方案。

[再次编辑]

所以,如果我的 ruby​​ 脚本(“test.rb”)是:

#!/usr/bin/env ruby
print "Hello"

我的 AppleScript 是:

do shell script "cd /testing_folder/; ruby test.rb"

然后我在 AppleScript 中返回“Hello”,但 ExtendScript 只会返回 true。

关于adobe-illustrator - File.execute() 没有执行我的脚本。如何调试这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20862868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com