web analytics

Setting password for Oracle listener in the script

Oracle listener control utility doesn’t allow to set the password non-interactively.
In this case the small Perl script, using Expect, could help.

use Expect;
my $exp = new Expect;

my $command = 'lsnrctl';

print "Changing pasword for ${LISTENER_NAME} \n" ;

$exp->spawn($command) or die "Cannot spawn $command: $!\n";


my $answer = $exp->expect(30, 'LSNRCTL>');
$exp->send("set current_listener ${LISTENER_NAME}\n");

$answer = $exp->expect(30, $PROMPT);

# For localized version should be changed (i.e. just to ':')
$answer = $exp->expect(30, 'Old password:');
# It's supposed, that listener still doesn't have the password

$answer = $exp->expect(30, 'New password:');

$answer = $exp->expect(30, 'Reenter new password:');

$answer = $exp->expect(30, $PROMPT);
$exp->send("set password\n");

$answer = $exp->expect(30, 'Password:');

$answer = $exp->expect(30, $PROMPT);

# Restart it if necessary
# $answer = $exp->expect(30, $PROMPT);
# $exp->send("reload\n");

$answer = $exp->expect(30, $PROMPT);


Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




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


A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.