applescript do shell命令“找不到命令"; [英] applescript do shell command "command not found"

查看:64
本文介绍了applescript do shell命令“找不到命令";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是applescript和命令行工具的新手.我安装了命令行工具来控制终端机中iMac的亮度.我安装了以下内容: https://github.com/nriley/brightness

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

安装后,我注意到/usr/local/bin/中有一个名为亮度"的新exec文件.

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

Internet告诉我,applescript只知道在/bin/sh中找到的命令行.在此处找不到亮度",并且我无法将exec文件复制到此目录.因此,在执行以下小程序时,出现错误"sh:亮度:未找到命令"是有道理的:

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"

现在有个大问题,为了使shell命令正常工作,我必须做什么?在终端中,该命令运行正常.我知道我可以执行以下操作:

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

但这总是使终端窗口处于活动状态,我想静默运行命令.

我很高兴获得详细说明.我在互联网上搜索了几天,但是,我是一个初学者.

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

推荐答案

提供完整路径

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

这篇关于applescript do shell命令“找不到命令";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆