ole*_*ass 7 macos installation homebrew expect
根据Homebrew安装说明,可以使用以下命令进行安装:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Run Code Online (Sandbox Code Playgroud)
这有效,但需要用户输入两次; 确认安装并在脚本调用的sudo提示符中:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
Run Code Online (Sandbox Code Playgroud)
Homebrew没有无人参与安装的参数,所以我能想到的唯一选择是以编程方式输入预期的数据.我试过使用expect,但我不能正确使用语法:
$ expect -c 'spawn ruby -e \"\$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";expect "RETURN";send "\n"'
ruby: invalid option -f (-h will show valid options) (RuntimeError)
send: spawn id exp7 not open
while executing
"send "\n""
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
现在正式支持无人值守安装 https://docs.brew.sh/Installation#unattended-installation:
如果您希望以非交互式方式运行 Homebrew 安装程序,并且不提示输入密码(例如在自动化脚本中),请
NONINTERACTIVE=1在安装命令之前添加。
$ NONINTERACTIVE=1 /bin/bash -c \
"$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Run Code Online (Sandbox Code Playgroud)
如果您想创建一个homebrew静默安装的安装脚本,那么只需将空白管道传递echo给自制程序的安装程序即可。然后将结果重定向到/dev/null@charles-duffy 建议的位置。
#!/usr/bin/env bash
# install.sh
URL_BREW='https://raw.githubusercontent.com/Homebrew/install/master/install'
echo -n '- Installing brew ... '
echo | /usr/bin/ruby -e "$(curl -fsSL $URL_BREW)" > /dev/null
if [ $? -eq 0 ]; then echo 'OK'; else echo 'NG'; fi
Run Code Online (Sandbox Code Playgroud)
$ ./install.sh
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4266 次 |
| 最近记录: |