目前我有一个 bash 脚本,它在通过 ssh 做一些事情时在其中使用期望。看起来像:
#!/bin/bash
#some bash stuff here
...
/usr/bin/expect -c '
spawn somescript.sh
expect "password:"
send "$PASSWD"
'
...
somescript.sh 通过 ssh 对远程服务器执行命令,但现在我的登录需要更改密码。我试过了
/usr/bin/expect -c '
spawn somescript.sh
expect "password:"
send "$PASSWD"
expect "current password"
send "$PASSWD"
expect "new password"
send "$NEWPASSWD"
'
但我收到一条错误消息:
WARNING: Your password has expired.\n Password change required but
no TTY available.