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

Discussion in 'Perl Misc' started by TP, Oct 23, 2003.

  1. TP

    TP Guest

    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
    --------------------------------->
     
    TP, Oct 23, 2003
    #1
    1. Advertising

  2. TP <> wrote:

    > 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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Oct 23, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ecPunk
    Replies:
    3
    Views:
    212
    Roland Hall
    Feb 14, 2004
  2. A. Fuentes

    Korn Shell vs. Perl

    A. Fuentes, Jun 30, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    100
    Tassilo v. Parseval
    Jun 30, 2003
  3. NNTP
    Replies:
    14
    Views:
    211
    Beardy
    Feb 11, 2004
  4. Feyruz
    Replies:
    4
    Views:
    2,200
    Sherm Pendley
    Oct 14, 2005
  5. moongeegee

    execute a shell script in a shell script

    moongeegee, Dec 3, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    253
    Ben Morrow
    Dec 4, 2007
Loading...

Share This Page