近来repo sync时经常需要多次输同样的密码:
sudo apt-get install expect
使用如下脚本来实现执行repo sync命令时自动输入口令:
#!/bin/bash
PASS="you psd"
expect -c "
set timeout -1
spawn -noecho repo sync
expect {
"*password:*" { send \"$PASS\r\"; exp_continue }
"*Password:*" { send \"$PASS\r\"; exp_continue }
eof { exit }
}
exit
"
本文介绍了一种使用expect脚本自动执行reposync命令并输入密码的方法。通过编写shell脚本结合expect工具,可以避免在执行reposync时重复手动输入密码,提高效率。
1848

被折叠的 条评论
为什么被折叠?



