macos - 错误“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,那将非常感谢!
解决方案
我复制并粘贴了您的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 run
有on run
.
推荐阅读
- php - 是否有任何内置函数可以将不同语言的日期转换为 PHP 中的通用日期格式
- wpf - wpf 数据网格中当前可见的列
- magento2 - Magento 2 Uncaught TypeError: 传递给 __construct() 的参数 1 必须是 Magento\Backend\Block\Template\Context 的实例
- wordpress - WordPress 永久链接将类别名称添加到帖子网址
- ios - Swift - 在 Xib 中动态设置 UITableView 高度
- ios - 当 LynnBubbleTableView 框架中的内容增长时,如何移动到 tableview 的底部?
- python-3.x - Python OpenCV--电子邮件不发送从 OpenCV 保存的图像
- java - java 11中isEmpty()和isBlank()方法的区别
- python - 如何在python中将数据框从月中转换为月度时间序列?
- django - 有没有办法使用 VS Code 调试在 vagrant 中运行的 Django 应用程序?