yum install expect -y
#!/bin/bash
account=abc
pwd='pwd[9'
expect << EOF
set timeout 300
spawn git clone https://github.com/abc/def.git
expect "Username"
send {$account}
send "\r"
expect "Password"
send {$pwd}
send "\r"
expect eof
EOF
由于密码含有特殊字符,这里通过{}
来进行处理
转载请注明出处: https://chrunlee.cn/article/linux-expect-info.html