[root@Remotehost ~]# Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0xc4cc170)', 60, 'New UNIX Password:') called at test-a-filehandle.pl line 82 main::change_password('linux-host\x{a}') called at test-a-filehandle.pl line 39 passwd amagana Changing password for user amagana. New UNIX password: #### $ssh->send("passwd amagana\n"); $ssh->expect(60, 'New UNIX Password:'); #linux $ssh->send( 'XxX*%xx,^xxxxXx_' . "\n"); $ssh->expect(60, 'Retype new UNIX password:'); #linux $ssh->send( 'XxX*%xx,^xxxxXx_' . "\n"); $ssh->expect(60, '#'); $ssh->send("exit\n"); $ssh->expect(60, '$'); $ssh->send("exit\n"); $ssh->close();