繁体   English   中英

错误“sh::command not found sh::command not found”编号 127

[英]error “sh: : command not found sh: : command not found” number 127

我正在尝试使用以下命令制作 AppleScript,当我运行它时,do shell 脚本命令出错。 我尝试在终端中运行它,它工作得非常好,所以我认为 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 脚本的 output 设为 var?

编辑 2:运行do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp"工作得很好,所以我认为它可能与 tmpdir

编辑 3:我再次运行它,它以某种方式工作得很好,所以如果有人知道如何使 output 成为一个 var,那将非常感谢!

我复制并粘贴了您的AppleScript代码并在Script Editor中运行它。 它运行没有错误,我看不出代码有什么问题。

要将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/'"

除非您有on run ,否则您不需要end run run 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM