#!/usr/bin/expect
# 设置超时时间:30s
set timeout 30
# expect须用spawn启动指定进程
spawn git push origin main
expect {
"Username" {
send "Username\r"
# exp_continue使expect继续执行,而非如常返回
exp_continue
}
"Password" {
send "Password\r"
exp_continue
}
}
Linux自动输入账号密码脚本 使用expect
于 2022-08-13 00:16:32 首次发布