<Snip from my earlier mail> -- I don't know if a return value can be gathered in a -- shell variable except by using ` chars. </Snip from my earlier mail>
Sorry, Stephen had already mentioned one other way: <Stephen's code> } | while read DOINK LINE; do if [ "$DOINK" = "DOINK" ]; then DBNAME="$LINE" # << Will do. </Stephen'Code> I take back that statement of mine. Gotta take Unix lessons. Thanks & regards, Charu. -----Original Message----- Sent: 06 November 2003 10:09 To: [EMAIL PROTECTED] 'Connected Thanks Stephen, The reason for using ` characters was because I wanted the output (a filename) in a variable. After that, the variable would be passed to other scripts for file creation, FTP etc. I don't know if a return value can be gathered in a shell variable except by using ` chars. I was trying to suppress 'Connected.' line using SQL*Plus itself. Once Stephane suggested grep (i.e. suppress from Unix), possibilities broadened considerably. I will keep the 'while read' option in mind for future. Thanks & regards, Charu. -----Original Message----- Behalf Of [EMAIL PROTECTED] Sent: 05 November 2003 21:15 To: Multiple recipients of list ORACLE-L 'Connected Rather than try to get output using the ` characters, see what you can do with this method: { sqlplus -s <<-XXX $USER/[EMAIL PROTECTED] set heading off feedback off trims on lines 300 pages 9999 set whatever else do this; do that; do the other thing; XXX } | while read LINE; do parse $LINE with sed, awk, whatever if [ this is true ]; then do something fi done If all you want is to do a simple select that is supposed to return one line, one cheap, but not especially robust, way of doing it is like { sqlplus -s <<-XXX $USER/[EMAIL PROTECTED] set heading off feedback off trims on lines 300 pages 9999 set whatever else select 'DOINK',name from v$database; -- or select 'DOINK '||name from v$database; XXX } | while read DOINK LINE; do if [ "$DOINK" = "DOINK" ]; then DBNAME="$LINE" fi done Now, if one is proficient in sed and awk, more elegant and robust means can be devised. > -----Original Message----- > From: Charu Joshi [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 05, 2003 6:05 AM > To: Multiple recipients of list ORACLE-L > Subject: SQL*Plus question - a bit urgent - Can we suppress > 'Connected.' > message? > > > Hello all, > > I am calling SQL*Plus from a unix shell script and storing the > results of the query executed in a shell variable. It goes like > this: > > FL_SUFFIX=`sqlplus -s /nolog <<EndOfSQL > SET ECHO OFF > SET FEEDBACK OFF > SET VERIFY OFF > SET PAGESIZE 0 > > CONN $ORA_ID/$ORA_PASS > > SELECT dummy FROM dual; -- Dummy query.. unrelated to > the question. > > EXIT SQL.SQLCODE > > EndOfSQL` > > But the contents of the FL_SUFFIX are 'Connected.' instead of the > value returned by the query. > > This is obviously because of the 'CONN $ORA_ID/$ORA_PASS' > statement. Is there a way to suppress the 'Connected.' message > that comes on connecting to database? > > I have thought about 2 solutions: > > 1. Use sqlplus -s $ORA_ID/$ORA_PASS :- This would be the last > alternative in case everything else fails .. obviously from > security point of view. > > 2. Create a .sql script as: > > SET ECHO OFF > SET FEEDBACK OFF > SET VERIFY OFF > SET PAGESIZE 0 > > SET TERMOUT OFF -- The important bits. > SPOOL /dev/null -- > CONN $ORA_ID/$ORA_PASS > SPOOL OFF -- > SET TERMOUT ON -- The important bits. > > SELECT dummy FROM dual; -- Dummy query. > > EXIT SQL.SQLCODE > > and then call this script as > > FL_SUFFIX=`sqlplus -s /nolog @a.sql` > > I think solution 2 will work, but I am loathe to writing a script > for a single SQL statement unless there is no other way. > > Any new ideas would be greatly appreciated, the quicker the > better. > > Thanks & regards, > Charu. > > ********************************************************* > Disclaimer > > This message (including any attachments) contains > confidential information intended for a specific > individual and purpose, and is protected by law. > If you are not the intended recipient, you should > delete this message and are hereby notified that > any disclosure, copying, or distribution of this > message, or the taking of any action based on it, > is strictly prohibited. > > ********************************************************* > > Visit us at http://www.mahindrabt.com > > > > -- > Please see the official ORACLE-L FAQ: http://www.orafaq.net > -- > Author: Charu Joshi > INET: [EMAIL PROTECTED] > > Fat City Network Services -- 858-538-5051 http://www.fatcity.com > San Diego, California -- Mailing list and web hosting services > ---------------------------------------------------------------- ----- > To REMOVE yourself from this mailing list, send an E-Mail message > to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB ORACLE-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing). > -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: <[EMAIL PROTECTED] INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ------------------------------------------------------------------ --- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). ********************************************************* Disclaimer This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ********************************************************* Visit us at http://www.mahindrabt.com -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Charu Joshi INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).