echo problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo problem
# 1  
Old 09-28-2010
echo problem

hi all
i have little problem below is my shell script
Code:
a=`sqlplus fss_cst/fss_cst@dolp1 << EOF
SET PAGESIZE 0 FEEDBACK OFF TRIMOUT ON;
select process from lfs$ta_process where valid_to_dat=to_date('9/16/2010','mm/dd/yyyy');
EOF`
echo ${SQL}

the script name is test2.sh

when i execute this ./test2.sh nothing happen and it shows blank
but if do it in the same in database then it shows the value
pls help me regarding this

Last edited by Scott; 09-28-2010 at 03:45 PM.. Reason: Please use code tags
# 2  
Old 09-28-2010
you are saving the return value in variable 'a', and not SQL...

Replace echo ${SQL} with $a and execute
# 3  
Old 09-28-2010
hi sorry that was my mistake i changed the variable too then it is gicing such type of message below

Code:
/svc/hin5/work/deepak1/C10 > ./test2.sh
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Sep 28 17:43:25 2010

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

SQL> SQL> 2 3 4 5 6
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

/svc/hin5/work/deepak1/C10>


Last edited by Scott; 09-28-2010 at 03:51 PM.. Reason: Code tags, please...
# 4  
Old 09-28-2010
Assuming that there is a table called lfs$ta_process we need to protect the dollar sign from the shell with a backslash.

You may find that after initial debugging "sqlplus -s" produces less garbage feedback.


Quote:
a=`sqlplus fss_cst/fss_cst@dolp1 << EOF
SET PAGESIZE 0 FEEDBACK OFF TRIMOUT ON;
select process from lfs\$ta_process where valid_to_dat=to_date('9/16/2010','mm/dd/yyyy');
EOF`
echo "${a}"
# 5  
Old 09-28-2010
Hi.

You might also want to use sqlplus -s
# 6  
Old 09-29-2010
hi all
i did both of the above thing still output is coming blank Smilie

don't know what is the problem

---------- Post updated at 07:09 AM ---------- Previous update was at 12:41 AM ----------

now i modified my script in such a way below

GetDBValue()
{
#
# Returns value from $DATABASE for the given select.
#
typeset SelectSQL=$1

sqlplus -s <<!EOF! | tr -d ' ' | read SQLValue
$DATABASE
SET PAGESIZE 0 FEEDBACK OFF TRIMOUT ON;
${SelectSQL}
!EOF!
RC=$?
}

GetDBValue " Select count(*) from gparams ; "

echo "${SQLValue}"


the name of the shell script is test4.sh here is the output

dolhin5/work/CR10 > ./test4.sh

dolhin5/work/CR10 >
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with echo command

I am trying to get ascii file using echo command, e.g. - echo "\050" It is correctly working on RHEL 4 but not in RHEL 5. Please help me to fix the issue. ## Working as expected in RHEL 4 $ lsb_release -d Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 8) $ echo... (4 Replies)
Discussion started by: atanubanerji
4 Replies

2. Shell Programming and Scripting

Simple echo problem

Hey all! I'm in an intro to UNIX class at university, and we've just began writing scripts. Naturally I can't get it to do what I want. Basic script as follows: COMPARE1=`ls|wc -l` tar czf archive.tgz ~/path/to/file COMPARE2=`tar tvzf archive.tgz|wc -l` if then ... (7 Replies)
Discussion started by: nickzourdos
7 Replies

3. Shell Programming and Scripting

echo display problem

Hi I am facing a strange problem a=03 echo ${a} the output is 3 But i want to display it is 03 Can you people help me how to display it like 03. Thanks (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

4. Shell Programming and Scripting

Double echo problem

I'm parsing a router configuration file and printing out some of the fields. Given the following output, I'd like to add the filename to the first column. I'm definately a neophyte in scripting. COUNTER=${#array1 } while ; do ######## echo -n $JUNOS_FILE | ... (3 Replies)
Discussion started by: nocleader
3 Replies

5. Shell Programming and Scripting

Problem with echo *

Hello all, Please help with the below. I have a requirement where in I have to read a pattern and print it as shown below. Patterns will be as below. Input Output Pattern Should be printed as below with spaces such that I can awk. -*--* - * - - * *--**... (2 Replies)
Discussion started by: tenderfoot
2 Replies

6. UNIX for Dummies Questions & Answers

echo $ problem

Hi I am using tcsh. I want display in a file_1 like this. $VARIBALE I gave in a termianl > echo "\$VARIBALE" > file_1 Its not workning. It was giving VARIBALE: Undefined variable. I gave \ before $, but why it was giving undefined varible? Please help me. Thanks in advance (4 Replies)
Discussion started by: chaitubek
4 Replies

7. Shell Programming and Scripting

echo problem

echo "XXXXX" >> /xx/output.txt cat /xx/file.txt| awk '{tony=tony+$1+$2; print tony/$3*100}' >> /xx/output.txt Dear all, In this situation i will have 2 lines in the output file. What i want is to have only one output line. e.g: XXXXX "value" HOW to put the output of the "cat and awk" in... (1 Reply)
Discussion started by: tontal
1 Replies

8. Shell Programming and Scripting

echo variable problem

hi I have say five variable. I would ask the user which one they want me to print and then print accordingly. TEST_1='10.2.3.4' TEST_2='11.2.3.5' TEST_3='12.2.3.5' TEST_4='13.2.3.5' TEST_5='14.2.3.5' print_var() { echo "Accessing var num $1" echo TEST$1 #??? But How do... (6 Replies)
Discussion started by: sabina
6 Replies

9. Shell Programming and Scripting

echo problem

Hi, I have given the following statement in a script to put the values of variables (VAR1, VAR2,...) in a file. echo " $VAR1 $VAR2 $VAR3 $VAR4 $VAR5" >> filename But the output is not coming properly. Variables VAR5, VAR4 are replacing the first (VAR1, VAR2,..). I can't... (5 Replies)
Discussion started by: abrd600
5 Replies

10. UNIX for Dummies Questions & Answers

`echo` problem.

Have the following lines in a script: echo "-----------------------------------------------"\ "---------------------" >> $xdfrpt echo "- Date - - / - /stand - /u - /u1 - /u2 -"\ "/x1 - /x2 - /x3 -" >> $xdfrpt echo... (1 Reply)
Discussion started by: Cameron
1 Replies
Login or Register to Ask a Question