首页 > 解决方案 > 错误“sh: : command not found sh: : command not found”编号 127

问题描述

我正在尝试使用以下命令制作 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,那将非常感谢!

标签: macosshellapplescript

解决方案


我复制并粘贴了您的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/'"

除非您end runon run.


推荐阅读