applescript do shell command “command not found”

安稳与你 提交于 2021-01-28 12:10:12

问题


I am new to applescript and command line tools. I installed a command line tool to control the brightness of the iMac in Terminal. I installed the following: https://github.com/nriley/brightness

After installing, I noticed a new exec file in /usr/local/bin/ called "brightness".

The Internet told me, that applescript only knows the command lines found in /bin/sh. "brightness" is not found there, and I can't copy the exec file to this directory. So it makes sense, that I get the error "sh: brightness: command not found", when executing the following applescript:

do shell script "brightness 0.7"

Now the big question, what do I have to do in order to get the shell command working? In Terminal, the command works fine. I know I could do the following:

tell application "Terminal"
activate
end tell
tell application "System Events"
    keystroke "brightness 0.7"
    keystroke return
end tell

But this always makes the terminal window active, and I want to run the command silently.

I am glad for detailed instructions. I searched the internet for days, but hey, I am a beginner.


回答1:


Provide the full path

do shell script "/usr/local/bin/brightness 0.7"


来源:https://stackoverflow.com/questions/34706728/applescript-do-shell-command-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!