Unable to capture sql output using shell script while running it through browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pssraju
    New Member
    • Jun 2007
    • 6

    Unable to capture sql output using shell script while running it through browser

    Hi,

    I am not sure whether I am posting it in right location as i cant see any shell scripting forum here. Below script works perfectly fine from command line, but when I run through browser I am not getting anything inside my $dt. Because of this its always going inside failure scenario. My procedure is going to return either Success / Failed output. Can anybody tell me where I am messing up.

    Code:
    #!/usr/bin/ksh
    
    if [ $REQUEST_METHOD == "POST" ]
    then
            QUERY_STRING=`line <&0`
    fi
    
    export TEMP_STRING=$QUERY_STRING
    
    User_ID=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) {if($i ~ /userid/) {print $i;} } }' | cut -f2 -d'='`
    
    SCRN_Token=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) { if($i ~ /scrntoken/) {print $i;} } }' | cut -f2 -d'='`
    
    SQLPLUS=`which sqlplus`
    FMUSER=username
    FMPASS=password
    FMSID=orasid
    
    REMOTE_ADDR=`env | grep "REMOTE_ADDR" | cut -f2 -d'='`
    NewToken="${REMOTE_ADDR}${User_ID}"
    
    dt=`$SQLPLUS -s $FMUSER/$FMPASS@$FMSID <<EOF
    set head off
    set pagesize 0
    set feedback off
    set serveroutput on feedback off
    exec validate_fm_user('$SCRN_Token', '$NewToken')
    quit
    EOF`
    
    echo dt is -$dt-
    
    if [ "$dt" != "Success" ]
    then
    #some error action
    exit 0
    fi
    Last edited by numberwhun; Nov 28 '07, 02:38 PM. Reason: add code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by pssraju
    Hi,

    I am not sure whether I am posting it in right location as i cant see any shell scripting forum here. Below script works perfectly fine from command line, but when I run through browser I am not getting anything inside my $dt. Because of this its always going inside failure scenario. My procedure is going to return either Success / Failed output. Can anybody tell me where I am messing up.

    Code:
    #!/usr/bin/ksh
    
    if [ $REQUEST_METHOD == "POST" ]
    then
            QUERY_STRING=`line <&0`
    fi
    
    export TEMP_STRING=$QUERY_STRING
    
    User_ID=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) {if($i ~ /userid/) {print $i;} } }' | cut -f2 -d'='`
    
    SCRN_Token=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) { if($i ~ /scrntoken/) {print $i;} } }' | cut -f2 -d'='`
    
    SQLPLUS=`which sqlplus`
    FMUSER=username
    FMPASS=password
    FMSID=orasid
    
    REMOTE_ADDR=`env | grep "REMOTE_ADDR" | cut -f2 -d'='`
    NewToken="${REMOTE_ADDR}${User_ID}"
    
    dt=`$SQLPLUS -s $FMUSER/$FMPASS@$FMSID <<EOF
    set head off
    set pagesize 0
    set feedback off
    set serveroutput on feedback off
    exec validate_fm_user('$SCRN_Token', '$NewToken')
    quit
    EOF`
    
    echo dt is -$dt-
    
    if [ "$dt" != "Success" ]
    then
    #some error action
    exit 0
    fi
    This is the Perl forum, for Perl coding questions. This question better belongs in the Unix Forum as Shell scripting is done on Unix. I am moving this thread over there.

    Regards,

    Jeff

    Comment

    Working...