473,770 Members | 3,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

6 New Member
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
1 4405
numberwhun
3,509 Recognized Expert Moderator Specialist
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

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

Similar topics

1
1707
by: bertoulin | last post by:
When I run my script via the shell (e.g. "php test.php") the script generates the correct output everytime. If I attempt to access the script via the web (e.g. http://localhost/test.php), Apache reports a segfault: - child pid 11005 exit signal Segmentation fault (11) Occasionally, the script will create vaild output to the browser (but this is rare). If I stop the httpd service and run "httpd -X", the script works flawlessly and...
1
3820
by: Pawel Banys | last post by:
Hello, There is an operation which can be performed at the shell prompt the following way: some_prg > result_file However, before "some_prg" can use files, they have to be converted and it can be done like this:
10
4993
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able to figure out the solution to this problem. First off, the server is Windows Server 2003 - Web Edition (IIS 6) and I'm using .Net Framework v1.1.4322.
8
6269
by: standish22 | last post by:
I want to programmatically capture an error that is done from a Shell command in VB.Net code. What I have is a Test.sql file that looks like --------------------------------------------------- select * from Table1 GO select * from Table2 GO
2
2851
by: Gerard Flanagan | last post by:
Hello, I have a third party shell script which updates multiple environment values, and I want to investigate (and ultimately capture to python) the environment state after the script has run. But running the script as a child process only sets values for that process, which are lost after execution. So I thought I could simply tack on an 'env' command line to the script input lines as shown below. However, using subprocess.Popen gives...
16
4856
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables recommended for reorg. My goal is to reorgchk and run reorgs based on entries in this reorg file as shown in the example below. I have tried my hand at the following failing script and hope that gurus here can throw me a lifeline of examples on how to...
1
5224
by: mlaris | last post by:
Howdy, We are experiencing a bizarre problem under Linux attempting to restore a DB2 database. The backup was created on this machine, and is being restored to the same machine, but changing the name of the database, and redirecting the tablespaces. The system is running DB2 Express C V9.5 and RHEL5 with latest updates The restore commands we are trying to run are as follows: RESTORE DATABASE CARDS FROM "/opt/rccs/data/backups"...
4
3518
by: mbatestblrock | last post by:
I hope this makes some sense. My ultimate goal here is to execute a block of code if the mouse has not moved in a minute or so within the broswer. The machine I am running this on is for internal use only, so I have no fear of this not working in certain browsers, etc. I am no javascript pro but know enough to catch on if anyone is kind enough to help me out here. One of the only ways I could see this working is by having js check the...
5
3163
by: vasilis | last post by:
I have a list box in a site with which I capture a selected value with the onChange event using the capture_value() function (code listed below). This function passes 2 arguments, i.e., 'str' which is the selected list box value and 'passed_url' which is a passed url for running a php script (which contains some url query parameters, e.g. 'somescript.php?var1=value1&var2=value2&var3=value3'). The capture_value() function actually sends a...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.