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