expect脚本实现sudo密码自动输入

#!/usr/bin/expect
set timeout 30
spawn sudo -E su
expect "password"
send "123456\n"
expect "root@"
send "source /home/123/.bashrc\n"
interact

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注