Currently I have a bash script that uses expect in it while doing some things over ssh. It looks like:
#!/bin/bash
#some bash stuff here
...
/usr/bin/expect -c '
spawn somescript.sh
expect "password:"
send "$PASSWD"
'
...
somescript.sh does commands to a remote server over ssh, but now my login requires a change of password. I've tried
/usr/bin/expect -c '
spawn somescript.sh
expect "password:"
send "$PASSWD"
expect "current password"
send "$PASSWD"
expect "new password"
send "$NEWPASSWD"
'
but I get an error saying:
WARNING: Your password has expired.\n Password change required but
no TTY available.
So, somescript.sh
makes an ssh
connection and then you get an error about TTY not being available.
Try -t
option!
From ssh man page:
-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g., when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With