简体   繁体   中英

error “sh: : command not found sh: : command not found” number 127

I am trying to make an AppleScript with the commands below and when I run it has an error with the do shell script command. I tried running this in terminal and it works perfectly fine so I think there's a problem with the AppleScript telling the shell script to execute. Does anybody have a solution? Also is it necessary to have an end run at the end of my script?

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

Edit: Also how would you make the output of the shell script a var?

Edit 2: Running do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp" works just fine so I think it may have to do with the tmpdir

Edit 3: I ran it again and it worked just fine somehow so if anyone knows how to make the output a var that would be great thanks!

I copied and pasted your AppleScript code and ran it in Script Editor . It ran without error and I see nothing wrong with the code .

To make what is returned from the do shell script command into a variable use, eg:

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

You do not need an end run unless you have an on run .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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