sub change_password { my ($host, $ssh) = @_; my ($pty) = $ssh->open2pty('passwd'); my $expect = Expect->init($pty); $expect->raw_pty(1); # $expect->log_user(1); if (answer_passwd($expect, 'current.*:', $old) and answer_passwd($expect, 'Enter new.*:', $new) and answer_passwd($expect, 'Retype new.*:', $new) and $expect->expect($timeout, "success")) { exit(0); } exit(1); }