我正在尝试创建一个安装ffmpeg的applescript。我有两个问题。
"
,该小脚本使我可以更改为'
,然后才能运行它,但在这种情况下它不起作用。 这里是我到目前为止的脚本。
tell application "Terminal"
do script "xcode-select --install && ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew install ffmpeg && brew install node && sudo chown -R $(whoami) /usr/local/bin /usr/local/etc && npm install --global ffmpeg-progressbar-cli"
activate
end tell
我尝试了这个,它似乎没有按预期的方式工作。
tell application "Terminal"
do script "sudo chown -R $(whoami) /usr/local/bin /usr/local/etc && xcode-select --install"
display dialog "Select OK once Xcode has installed" buttons {"OK"} default button 1
do script "ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)""
display dialog "Select OK once Homebrew has installed" buttons {"OK"} default button 1
do script "brew install ffmpeg"
display dialog "Select OK once ffmpeg has installed" buttons {"OK"} default button 1
do script "brew install node"
display dialog "Select OK once node has installed" buttons {"OK"} default button 1
do script "npm install --global ffmpeg-progressbar-cli"
display dialog "Select OK once ffmpeg-bar has installed" buttons {"OK"} default button 1
activate
end tell
对于第二个问题,必须是
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
但是applescript让我将其更改为
ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'
单引号无效。
帮助和建议感激!
[确定,请尝试以下脚本,但是请注意以下警告:
shellScriptHandler("xcode-select --install", false)
shellScriptHandler("sudo chown -R $(whoami) /usr/local/Cellar", true)
shellScriptHandler("ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\" <<< " & return, false)
shellScriptHandler("sudo chown -R $(whoami) /usr/local/var/homebrew /usr/local/share/zsh /usr/local/share/zsh/site-functions", true)
shellScriptHandler("/usr/local/Homebrew/bin/brew install ffmpeg", false)
shellScriptHandler("/usr/local/Homebrew/bin/brew install node", false)
shellScriptHandler("sudo chown -R $(whoami) /usr/local/bin /usr/local/etc", true)
shellScriptHandler("/usr/local/bin/npm install --global ffmpeg-progressbar-cli", false)
on shellScriptHandler(command, usesAdmin)
log command
(*
The try block catches any errors and reports them; the user can choose
to continue execution if it's a warning, or cancel execution outright.
The 'eval' statement forces do shell script to read the standard
interactive $PATH variable, so that it sees /user/local/, otherwise it
can't find the files it needs.
*)
try
do shell script "eval `/usr/libexec/path_helper -s`; " & command administrator privileges usesAdmin
on error errstr
display dialog errstr buttons {"Continue", "Cancel"} default button "Continue"
end try
end shellScriptHandler
注意事项:
chown
命令。当我运行ruby脚本和brew install...
时,这些错误弹出。您可能会基于不同系统中的特性而遇到其他此类错误,但是添加更多此类命令以理顺/ usr / local中的权限应该没有什么害处。