簡體   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