calling Korn shell from Perl script - changing oracle db passwords through web

T

TP

I'm trying to write a program to change oracle db user password in
multiple databases.

I've created following html file to except login id and new password
and pass these parameters to test.pl script.

test.pl script should call tom_reset ksh script that will reset the
password. I tested tom_reset script and it works. My problem is how
can I make check to see if tom_reset script actually ran successfully.

Tom....

<---------------Below is my test.pl script:---------------------->

#!/usr/bin/perl -w
use strict;
use CGI qw(param); # Common Gateway Interface
Module
use vars qw($checkuser $pwd $pwd2);
print "Content-Type: text/html\n\n";
#Passed Variables

(defined param("checkuser")) ? ($checkuser = param("checkuser")) :
($checkuser = "");
(defined param("pwd")) ? ($pwd = param("pwd")) : ($pwd = "");
(defined param("pwd2")) ? ($pwd2 = param("pwd2")) : ($pwd2 = "");

if ($pwd eq $pwd2) {
print "The password for Oracle account $checkuser has been
changed to: $pwd<BR>";
#system("tom_reset($checkuser,$pwd,$pwd2)");
} else {
alert_pwd_notmatching();
}

sub alert_pwd_notmatching {

print <<HTML;
<SCRIPT LANGUAGE="JavaScript">
<!-- hide script from old browsers
alert("The passwords you have submitted do not match.
Please try again.");
history.go(-1);
//-->
</SCRIPT>
HTML
}

<------------------------- end of test.pl
------------------------------>

<---------------------------Below is my tom_reset
script----------------->
#!/bin/ksh
.. /opt/bin/Gsu

USRID=check_usr
.. /opt/bin/.setps_apps
clear
DASH="--------------------------------------------------"
echo ""
echo $DASH
echo This program will reset user password in all the databases...
echo $DASH
echo ""


CHECK_USER=$1
PWD=$2
PWD2=$3
echo ""
if [ "$PWD" != $PWD2 ]
then
clear
echo "Passwords do no match...good-bye!"
echo ""
exit
fi
echo ""
echo The program is resetting.....
echo ""
for db in `/bin/cat file`; do
echo ""
echo resttting password in +++ $db +++ for user account $CHECK_USER
echo ""
{ echo $USRID/$PASWD@$db; echo "define username=$CHECK_USER"; echo
"define password=$PWD"; cat reset.sql; } | $ORACLE_HOME/bin/sqlplus -S
done



exit 0

<-------------------------end of tom_reset
--------------------------------->
 
T

Tad McClellan

TP said:
I'm trying to write a program to change oracle db user password in
My problem is how
can I make check to see if tom_reset script actually ran successfully.


The documentation for the function you are using describes how
to do that.

If you don't understand what the documentation says, then ask a
question about what the documentation says.

If you haven't read the documentation for the functions that you
are using, then you shouldn't be posting to Usenet until you have.

This is not a read-the-docs-to-me service...

#!/usr/bin/perl -w
use strict;
use CGI qw(param); # Common Gateway Interface


"password" and "CGI" should never be mentioned without also
mentioning "taint checking" (-T).

perldoc perlsec

#system("tom_reset($checkuser,$pwd,$pwd2)");


If you are concerned with security (and you ought to be) then
you should not be using that form of system() call because it
may invoke a shell, and shells are easy to trick.

And that isn't how you call an external program anyway, did you
instead mean:

system("tom_reset $checkuser $pwd $pwd2");

??


perldoc -f system

The return value is the exit status of the program
as returned by the "wait" call. To get the actual
exit value shift right by eight (see below).


system 'tom_reset', $checkuser, $pwd, $pwd2 and
die "tom_reset failed";

or

!system 'tom_reset', $checkuser, $pwd, $pwd2 or
die "tom_reset failed";

or

if ( system 'tom_reset', $checkuser, $pwd, $pwd2 ) {
my $exit_value = $? >> 8;
die "tom_reset failed with exit code $exit_value";
}


if [ "$PWD" != $PWD2 ]


Why quotes on one and no quotes on the other?

then
clear
echo "Passwords do no match...good-bye!"
echo ""
exit


exit 1 # or some other non-zero value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top