|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
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 09:11 AM.. Reason: added spool commands |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
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
|
||||
|
||||
|
Please post the code you're using.
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
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 |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
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 '' |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
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. |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What does following echo command do? | akash_mahakode | Shell Programming and Scripting | 1 | 11-16-2009 03:56 AM |
| echo command and piping | rushhour | UNIX for Dummies Questions & Answers | 4 | 02-16-2009 02:06 PM |
| Echo command with $$ $# $@ | howdy | UNIX for Dummies Questions & Answers | 3 | 11-18-2008 03:32 PM |
| echo statement issue | subin_bala | Shell Programming and Scripting | 3 | 04-24-2008 02:13 AM |
| Nested Echo Command Help | findprakash | UNIX for Dummies Questions & Answers | 2 | 09-22-2007 12:26 AM |
|
|