freelanceprogrammers.org Forum Index » Perl
How do I pipe to an interactive program?
Joined: 12 May 2005
Posts: 1
How do I pipe to an interactive program?
Hi,
I am trying to write a perl script that calls Oracle lsnrctl and
resets the listener password. The problem is that once I am into
lsnrctl and issue the change_password command the utility prompts
for the old and new passwords. When I try to write to the process
at this point I get a no tty error. Anybody got any suggestions?
Thanks,
John
P.S. Here is the script:
#!/ora01/app/oracle/product/OraDb10g/perl/bin/perl
$_=$ARGV[0];
s/^s*(.*?)s*$/$1/; #trim any whitespace off of the password
argument
if($_){
my $launch= "| lsnrctl";
open(LProcess, $launch) or setErrorMsg("Unable to launch lsnrctl
process.");
print LProcess "CHANGE_PASSWORD
"
print LProcess "
"; # this is an empty old
password
print LProcess "$_
"; # new password the first time
print LProcess "$_
"; # new password the second
time
print LProcess "SAVE_CONFIG
"; # save the new configuration
close(LProcess);
exit 0;
}
else{
setErrorMsg("No password was supplied for the listener.");
}
#===========================================================
# This is a subroutine to set the error message in the
# environment variable ERROR_MSG and exit with a 1 value
#===========================================================
sub setErrorMsg{
my $msg = shift;
print $msg;
exit 1;
}
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







