我试图用下面的命令制作一个AppleScript,当我运行它时,do shell script命令出错。我尝试在终端中运行此程序,它工作得很好,所以我认为AppleScript告诉Shell脚本执行存在问题。有人有解决方案吗?还需要end run
在脚本末尾添加一个吗?
do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp &&
xxd -p -l 3 -s 54 $TMPDIR/test.bmp |
sed 's/\\(..\\)\\(..\\)\\(..\\)/\\3\\2\\1/'"
编辑:另外,您将如何使Shell脚本的输出为var?
编辑2:运行do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp"
正常,所以我认为可能与tmpdir有关
编辑3:我再次运行它,它以某种方式正常工作,因此,如果有人知道如何将输出设为var,那将非常感谢!
我复制并粘贴了AppleScript 代码,然后在脚本编辑器中运行了它。它运行没有错误,我认为代码没有错。
要将do shell script
命令返回的内容转换为变量,请使用例如:
set hexColor to do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp &&
xxd -p -l 3 -s 54 $TMPDIR/test.bmp |
sed 's/\\(..\\)\\(..\\)\\(..\\)/\\3\\2\\1/'"
end run
除非您有一个,否则您不需要on run
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句