For reference, again because I forget these things usually, here is a simple expect script that ssh’s to a server and changes the password.

#!/usr/bin/expect
set node [lindex $argv 0]
spawn ssh $node passwd
expect "(current) UNIX password:" { send "oldpass\r" }
expect "New password: " { send "newpass\r" }
expect "Retype new password: " { send "newpass\r" }
send "exit\r"

I can call this like, “expect_chpass nodename” and voilĂ , oldpass is changed to newpass.

Now go do something less boring instead.

About troyski

I'm a freelance UNIX engineer working in the UK. I'm married to Tina and between us we have six children. I'm a bit of an Apple fan boy, and all the Windows machines in the house are a thing of the past now.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post navigation