目前我有一個bash腳本,它在使用expect期間通過ssh執行某些操作。它看起來像:期望通過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.
我試過了-t選項,但是錯誤仍然存在 – dwu