更新时间:2023-12-05 14:00:28
产卵的预计会话中的bash脚本是通常你是如何自动化交互提示。
Spawning an expect session within your bash script is typically how you automate interactive prompts.
例如
expect -c "
spawn sudo setpci -s 00:02.0 F4.B=00
expect -nocase \"password:\" {send \"$PASS\r\"; interact}
"
请注意,这不是在这种情况下推荐的方法,因为它是一个大安全漏洞来存储你的root密码在bash脚本。
Note that this isn't the recommended approach in this case as it is a huge security hole to store your root password in a bash script.
正确的解决办法是修改的/ etc / sudoers文件/
不提示您为二进制的密码。
The correct solution would be to edit your /etc/sudoers/
to not prompt you for a password for that binary.
#in /etc/sudoers
neohexane ALL=(ALL) NOPASSWD : /usr/bin/setpci