set echo off command issue


 
Thread Tools Search this Thread
Operating Systems Linux set echo off command issue
# 1  
Old 03-11-2010
Error set echo off command issue

Hi all,
I am executing a Oracle SQL statement in a shell script and spooling the output of the query into a File with spool command.
I want to ensure that only output of the query appears in file excluding the SQL statement but even set echo off command is not working.
Please help
# 2  
Old 03-11-2010
Here's what I do...

Code:
sqlplus -s /nolog <<-EOF
   whenever oserror exit failure
   whenever sqlerror exit failure rollback
   set heading off pagesize 0 feedback off linesize 400
   set trimout on trimspool on termout off echo off sqlprompt ''

   connect $SQLUSER/$SQLPWD@$DB

   spool $spoolfile

   select * from mytable;

   spool off

   exit

EOF


Last edited by jsmithstl; 03-11-2010 at 10:11 AM.. Reason: added spool commands
# 3  
Old 03-11-2010
Hi Jsmithstl,
I am using spool command to write the output of the query in a file
But Query appears in the file along with the Query output.
I just want the output of the query in the file.
Ex: this is what currently apperas in the file test.txt=>
SELECT COUNT(*) FROM USER_TAB_COLUMNS RET WHERE RET.COLUMN_NAME ='EMPLOYEE_ID';

4

spool off;

But what is want the file to contain is just the output of the above written query i.e: 4
How do i go about it using spool command as even the statement echo off doesnt seem to work
# 4  
Old 03-11-2010
Please post the code you're using.
# 5  
Old 03-11-2010
i tried the script attached by you.
And it worked thanks a lot!!!!!!!!
By the way Jsmithstl i would be highly obliged if you can tell me what part of the code provided by you prevented the query from being printed in the spooled file.
Please do reply to this ping cause it would be really helpful
# 6  
Old 03-11-2010
It works for me:

CODE:
Code:
$ cat tsql.ksh
#!/usr/bin/ksh

. ~/.profile

SQLUSER=xxxxxxx
SQLPWD=xxxxxxx
DB=mydb

SPOOLFILE=blah.out

sqlplus -s /nolog <<-EOF
   whenever oserror exit failure
   whenever sqlerror exit failure rollback
   set heading off pagesize 0 feedback off linesize 400
   set trimout on trimspool on termout off echo off sqlprompt ''

   connect $SQLUSER/$SQLPWD@$DB

   spool $SPOOLFILE

   select 'I only see my query output' from dual;

   spool off

   exit

EOF

exit

RESULTS:
Code:
$ ./tsql.ksh
I only see my query output

$ cat blah.out
I only see my query output

$



---------- Post updated at 08:55 AM ---------- Previous update was at 08:53 AM ----------

These lines:
Code:
   set heading off pagesize 0 feedback off linesize 400
   set trimout on trimspool on termout off echo off sqlprompt ''

# 7  
Old 03-13-2010
set echo off command issue

Hi Smith,
Sorry for the late response.
First things first i need to thank you for the timely help.
Yes you are write it works and the reason for the same is cause sqlplus runs in silent mode i.e. sqlplus -S[ilent] which printing of all command execution steps are supressed though one thing still baffles me why doesnt set echo off command work????

Again thanks for your quick response and hope that i would prove to you all of some help in future.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

2. Shell Programming and Scripting

Issue while using echo command

Hi, I have below shell script.. $ cat /tmp/1.txt NAME-HOST-APPLIED TIME-DATE $ cat /tmp/1.sh #!/bin/ksh echo "<html><table border size=1>" > /tmp/mail.html for i in `cat /tmp/1.txt` do a1=`echo $i |cut -d "-" -f1` a2=`echo $i |cut -d "-" -f2` a3=`echo $i |cut -d "-" -f3` a4=`echo $i... (4 Replies)
Discussion started by: thomasraj87
4 Replies

3. UNIX for Dummies Questions & Answers

set echo off and on

Hi I have written a bash script to capture the output of jmap. The command i execute is jmap -heap <pid> This gives details of memory usage of the process with <pid>. Now jmap not only gives this info but also prints couple more lines, which i am not interested in. Here are the lines that I... (3 Replies)
Discussion started by: avinthm
3 Replies

4. Shell Programming and Scripting

Issue in echo

Hi Friends, I am trying a very simple thing to print through bash shell scripting using echo but failing. My script is- A=Abha B=Biha C=2011 D=5 echo " The name is $A_$B$C0$D" It should print- "The name is Abha_Biha201105" but it's printing something else. Is my script wrong?... (2 Replies)
Discussion started by: NARESH1302
2 Replies

5. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

6. Shell Programming and Scripting

why the set rr='echo string|cut not working

I am new to the c shell script, can you let me know why the set rr= is not working. C shell script #! /bin/csh Set tt= 12345_UMR_BH452_3_2.txt set rr='echo $tt | cut –d”_” -f1' syntax error (4 Replies)
Discussion started by: jdsignature88
4 Replies

7. Shell Programming and Scripting

echo statement issue

Hi All, I am pasting my code below if # e means file exists then echo OFR_Configlist exists >> OFR_Backup_Configfiles.log else echo OFR_Configlist Not exists >> OFR_Backup_Configfiles.log exit fi How can i show the echo message in console also at the same time? I dont want to write... (3 Replies)
Discussion started by: subin_bala
3 Replies

8. Shell Programming and Scripting

echo just 1 line before execution/set +-x

Suppose that you want to mostly not echo commands inside your script during execution (e.g. to not bog the user down with details that they do not care about) but that there is the occaisional script line that you would like to echo before you execute it. Is there an elegant way to achieve this?... (3 Replies)
Discussion started by: fabulous2
3 Replies

9. UNIX for Dummies Questions & Answers

set variable to Home, then echo it to screen

Major Newbie here folks. I'm trying to set a variable to my Home directory and then echo it to the screen. Any and all help is greatly appreciated. Thanks Anna (3 Replies)
Discussion started by: amidget
3 Replies

10. Shell Programming and Scripting

How to set echo on

I'm looking at my bash man page and I'm expecting to find some option that I can use to make it echo every command that it executes. The description of --verbose was pretty terse! Is --verbose supposed to make it echo every command it executes? My bash script script (named ws2) contains a... (1 Reply)
Discussion started by: siegfried
1 Replies
Login or Register to Ask a Question