Google
Web tarasdom.com

 

Changing password for Oracle listener

It is difficult to change the password for Oracle listener from the batch file. The small Perl script could help with this problem.
#!/usr/bin/perl
use Expect;
my $exp = new Expect;
my $command = 'lsnrctl';
my $PROMPT='LSNRCTL>';
my $LISTENER_NAME=$ARGV[0] ;
my $NEW_PASSWORD=$ARGV[1] ;
print "Changing pasword for ${LISTENER_NAME} \n" ;
$exp->spawn($command) or die "Cannot spawn $command: $!\n";
$exp->stty(qw(echo));
my $answer = $exp->expect(30, 'LSNRCTL>');
$exp->send("set current_listener ${LISTENER_NAME}\n");
$answer = $exp->expect(30, $PROMPT);
$exp->send("change_pass\n");
# For localized version should be changed (i.e. just to ':')
$answer = $exp->expect(30, 'Old password:');
# It is supposed,that listener still doesn't have the password
$exp->send("\n"); 
$answer = $exp->expect(30, 'New password:');
$exp->send("${NEW_PASSWORD}\n");
$answer = $exp->expect(30, 'Reenter new password:');
$exp->send("${NEW_PASSWORD}\n");
$answer = $exp->expect(30, $PROMPT);
$exp->send("set password\n");
$answer = $exp->expect(30, 'Password:');
$exp->send("${NEW_PASSWORD}\n");
$answer = $exp->expect(30, $PROMPT);
$exp->send("save_config\n");
# Restart it if necessary
# $answer = $exp->expect(30, $PROMPT);
# $exp->send("reload\n");
$answer = $exp->expect(30, $PROMPT);
$exp->send("exit\n");
exit;

©
Page was modified 24.07.2006