From: Keith C. <kei...@ya...> - 2010-12-09 17:02:04
|
Here is my sub to login and change a password my $spawnCmd="ssh $connStr -n '/usr/bin/passwd'"; $exp->log_stdout(0); $exp->log_file("kac","w"); my $timeout=$self->{'timeOut'}; $exp->raw_pty(1); $exp->exp_internal(1); unless ( $exp->spawn("$spawnCmd") ) { return wantarray ? ("2","Unable to spawn command to check for login") : "2"; } $exp->expect($timeout,"assword:","PASSCODE:"); print "Match: " . $exp->match() . "\n"; $exp->send("$oldpass\r"); $exp->expect($timeout, "ld password:", exp_continue); $exp->send("$oldpass\r"); $exp->expect($timeout,"choice here:"); $exp->send("p\r"); $exp->expect($timeout,"ew password:"); $exp->send("$newpass\r"); $exp->expect($timeout,"Re-enter"); $exp->send("$newpass\r"); $exp->expect($timeout,"successfully"); $exp->log_stdout(0); my $timeout=$self->{'timeOut'}; my $matchString=$exp->match(); $exp->hard_close(); if ( $matchString eq "successfully" ) { return wantarray ? ("1","Password changed.") : "1"; } Here is the error I get: Enter Securid PASSCODE: Not a terminal stty: : Not a typewriter stty: : Not a typewriter stty: : Not a typewriter ^[[3g ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[HChanging password for <user_id_deleted> pam_chauthtok: System error Any help is appreciated. |