By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,350 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,350 IT Pros & Developers. It's quick & easy.

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

P: 6
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.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/ksh
  2.  
  3. if [ $REQUEST_METHOD == "POST" ]
  4. then
  5.         QUERY_STRING=`line <&0`
  6. fi
  7.  
  8. export TEMP_STRING=$QUERY_STRING
  9.  
  10. User_ID=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) {if($i ~ /userid/) {print $i;} } }' | cut -f2 -d'='`
  11.  
  12. SCRN_Token=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) { if($i ~ /scrntoken/) {print $i;} } }' | cut -f2 -d'='`
  13.  
  14. SQLPLUS=`which sqlplus`
  15. FMUSER=username
  16. FMPASS=password
  17. FMSID=orasid
  18.  
  19. REMOTE_ADDR=`env | grep "REMOTE_ADDR" | cut -f2 -d'='`
  20. NewToken="${REMOTE_ADDR}${User_ID}"
  21.  
  22. dt=`$SQLPLUS -s $FMUSER/$FMPASS@$FMSID <<EOF
  23. set head off
  24. set pagesize 0
  25. set feedback off
  26. set serveroutput on feedback off
  27. exec validate_fm_user('$SCRN_Token', '$NewToken')
  28. quit
  29. EOF`
  30.  
  31. echo dt is -$dt-
  32.  
  33. if [ "$dt" != "Success" ]
  34. then
  35. #some error action
  36. exit 0
  37. fi
  38.  
Nov 28 '07 #1
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
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.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/ksh
  2.  
  3. if [ $REQUEST_METHOD == "POST" ]
  4. then
  5.         QUERY_STRING=`line <&0`
  6. fi
  7.  
  8. export TEMP_STRING=$QUERY_STRING
  9.  
  10. User_ID=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) {if($i ~ /userid/) {print $i;} } }' | cut -f2 -d'='`
  11.  
  12. SCRN_Token=`echo $TEMP_STRING | awk 'BEGIN {FS="&"} { for (i=1; i<=NF; i++) { if($i ~ /scrntoken/) {print $i;} } }' | cut -f2 -d'='`
  13.  
  14. SQLPLUS=`which sqlplus`
  15. FMUSER=username
  16. FMPASS=password
  17. FMSID=orasid
  18.  
  19. REMOTE_ADDR=`env | grep "REMOTE_ADDR" | cut -f2 -d'='`
  20. NewToken="${REMOTE_ADDR}${User_ID}"
  21.  
  22. dt=`$SQLPLUS -s $FMUSER/$FMPASS@$FMSID <<EOF
  23. set head off
  24. set pagesize 0
  25. set feedback off
  26. set serveroutput on feedback off
  27. exec validate_fm_user('$SCRN_Token', '$NewToken')
  28. quit
  29. EOF`
  30.  
  31. echo dt is -$dt-
  32.  
  33. if [ "$dt" != "Success" ]
  34. then
  35. #some error action
  36. exit 0
  37. fi
  38.  
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
Nov 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.