如何转换bash';s命令替换和管道到Applescript?
我需要帮助将这个简单的shell脚本转换为apple脚本 这是因为它将用于Automator工作流,因此我需要打开Terminal窗口,这是使用shell脚本无法完成的 shell脚本如下所示:如何转换bash';s命令替换和管道到Applescript?,bash,shell,terminal,applescript,sh,Bash,Shell,Terminal,Applescript,Sh,我需要帮助将这个简单的shell脚本转换为apple脚本 这是因为它将用于Automator工作流,因此我需要打开Terminal窗口,这是使用shell脚本无法完成的 shell脚本如下所示: java -classpath `dirname "$1"` `basename "$1" | sed "s/.class//g"` 这将获得文件的位置,然后是文件名,然后去掉文件扩展名“.class”,然后使用Java命令运行它。例如,它将生成以下命令: java -classpath /users
java -classpath `dirname "$1"` `basename "$1" | sed "s/.class//g"`
这将获得文件的位置,然后是文件名,然后去掉文件扩展名“.class”,然后使用Java命令运行它。例如,它将生成以下命令:
java -classpath /users/desktop/ filename
我需要转换这个命令,使其与Applescript一起工作,这样我就可以看到应用程序在终端窗口中运行。它将以如下方式开始:
on run {input, parameters}
tell application "Terminal"
activate
do shell script "java -classpath path/to/ file"
end tell
end run
如何将文本转换移植到Applescript?我看到的唯一问题(现在)是将do shell script
更改为do script
。除此之外,您已经正确启动了它。我假设您希望将(a)个文件引用传递给shell脚本。这相当简单
set these_files to (choose file with multiple selections allowed)
repeat with this_file in these_files
tell application "Finder" to if the name extension of this_file is "class" then my do_shell_script(this_file)
end repeat
on do_shell_script(this_file)
tell application "Terminal" to activate --makes 'Terminal' the frontmost application
--'do shell script ...' goes here
--To refer to a file/folder for a 'do shell script', do something like the command below...
--do shell script "mdls -name kMDItemLastUsedDate " & quoted form of the POSIX path of this_file
end do_shell_script
我现在看到的唯一问题是将do shell脚本
更改为do脚本
。除此之外,您已经正确启动了它。我假设您希望将(a)个文件引用传递给shell脚本。这相当简单
set these_files to (choose file with multiple selections allowed)
repeat with this_file in these_files
tell application "Finder" to if the name extension of this_file is "class" then my do_shell_script(this_file)
end repeat
on do_shell_script(this_file)
tell application "Terminal" to activate --makes 'Terminal' the frontmost application
--'do shell script ...' goes here
--To refer to a file/folder for a 'do shell script', do something like the command below...
--do shell script "mdls -name kMDItemLastUsedDate " & quoted form of the POSIX path of this_file
end do_shell_script
我一点也不懂AppleScript,但我想您可以在
do shell script
行中调用现有的shell脚本,而不是在AppleScript中尝试重新执行字符串操作
注:看起来您希望能够通过单击(或拖放等)调用Java类。您的方法只适用于匿名包中的类,即没有任何
包源代码开头的代码>声明。对于其他人,您可以尝试找出它们在哪个包中。我不知道怎么做。无论如何,可分发程序应该在jar归档中,在那里您应该能够使用java-jar…
)我根本不知道AppleScript,但我想您可以在do shell script
行中调用现有的shell脚本,而不是尝试在AppleScript中重新执行字符串操作
注:
看起来您希望能够通过单击(或拖放等)调用Java类。您的方法只适用于匿名包中的类,即没有任何包源代码开头的代码>声明。对于其他人,您可以尝试找出它们在哪个包中。我不知道怎么做。无论如何,可分发程序应该在jar存档中,在那里您应该能够使用java-jar…
)记住使用posix的引用形式path@Flambino哇,我没看见。谢谢,我会修好的drember使用posix的引用形式path@Flambino哇,我没看见。谢谢,我会修好的D