| 1 |
#!/usr/bin/expect |
| 2 |
|
| 3 |
set timeout 2 |
| 4 |
expect_after default {puts stderr "\nFAIL"; exit 1} |
| 5 |
|
| 6 |
spawn /bin/sh |
| 7 |
send "if \[ \$(id -u) -eq 0 \]; then PS1='# '; else PS1='$ '; fi\r" |
| 8 |
expect "# " |
| 9 |
|
| 10 |
send "expiry -f\r" |
| 11 |
expect "Your password has expired. Choose a new password." |
| 12 |
expect "Enter new UNIX password: " |
| 13 |
send "password\r" |
| 14 |
expect "Retype new UNIX password: " |
| 15 |
send "password\r" |
| 16 |
expect "passwd: password updated successfully" |
| 17 |
expect "# " |
| 18 |
send "echo \$?\r" |
| 19 |
expect "0" |
| 20 |
expect "# " |
| 21 |
send "exit\r" |
| 22 |
puts "OK\n" |
| 23 |
exit 0 |