Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Run a script at the OS command prompt
On Jul 3, 10:31 am, Sashi <small..._at_gmail.com> wrote:
> On Jul 3, 12:48 pm, "fitzjarr..._at_cox.net" <fitzjarr..._at_cox.net> wrote:
>
>
>
>
>
> > On Jul 3, 10:38 am, Sashi <small..._at_gmail.com> wrote:
>
> > > > Go to Morgan's Library atwww.psoug.org.
> > > > Scroll down to UNIX/vi
> > > > Scroll down to SQL*Plus Shell Script Demo
> > > > --
> > > > Daniel A. Morgan
> > > > University of Washington
> > > > damor..._at_x.washington.edu (replace x with u to respond)
> > > > Puget Sound Oracle Users Groupwww.psoug.org
> > > > Go to Morgan's Library atwww.psoug.org.
> > > > Scroll down to UNIX/vi
> > > > Scroll down to SQL*Plus Shell Script Demo
> > > > --
> > > > Daniel A. Morgan
> > > > University of Washington
> > > > damor..._at_x.washington.edu (replace x with u to respond)
> > > > Puget Sound Oracle Users Groupwww.psoug.org
>
> > > OK. A here document is a good idea and it should work.
>
> > > But my output is still the same:
> > > Each record of the output is preceded by the column headings. I can
> > > clean it up inside vim or use awk/sed etc but that just doesn't seem
> > > right.
> > > Why is this happening? Please see my sample output below.
> > > As you can see, my record structure has 5 columns. Every output record
> > > has the column headings.
> > > How do I avoid this?
>
> > > SITE_KEY SITE_ID
> > > ----------
> > > ------------------------------------------------------------
> > > SITE_MGR_1
> > > --------------------------------------------------------------------------------
> > > SITE_MGR_2
> > > --------------------------------------------------------------------------------
> > > RECORD_CR RECORD_UP
> > > --------- ---------
> > > 2305 Site02592
>
> > > 07-MAY-07
>
> > > SITE_KEY SITE_ID
> > > ----------
> > > ------------------------------------------------------------
> > > SITE_MGR_1
> > > --------------------------------------------------------------------------------
> > > SITE_MGR_2
> > > --------------------------------------------------------------------------------
> > > RECORD_CR RECORD_UP
> > > --------- ---------
> > > 2306 Site02593
>
> > > 07-MAY-07
>
> > > ^C----------
> > > ------------------------------------------------------------
> > > 2307 Site02594
>
> > > 3058 rows selected.- Hide quoted text -
>
> > > - Show quoted text -
>
> > Reading the manuals would help tremendously:
>
> > set head off
>
> > Turns off the heading entirely.
>
> > set pagesize <some number here greater than 14>
>
> > Reduces the number of headers you get because you usually print them
> > at the top of a page.
>
> > set termout off
>
> > Turns off the terminal output when running a script. This is good for
> > dumping data to a file.
>
> > Again, this is ALL found in the documentation at:
>
> >http://tahiti.oracle.com
>
> > David Fitzjarrell
>
> Thanks, David.
> I will RTFM. I googled around for sqlplus options but didn't see
> these. I was expecting to be able to pass these options as flags to
> sqlplus and didn't realize that I needed to set the env vars.
>
> Regards,
> Sashi
Also see http://www.orafaq.com/faq/sqlplus
Another variant of running sqlplus is:
schemapassword=scott/tiger
echo "$schemapassword
set verify off
set echo off
set feedback off
set pages 0
set heading off
set termout off
<your sql commands>
" | sqlplus -s > youroutputfile
This has the advantage of not letting others see the password with a ps. It also shows a way to pass parameters from a script to sqlplus.
There is a sqlplus manual at tahiti.oracle.com, as well as many examples floating about the net (and metalink, if you have access). sqlplus even has html output options. Do a show all at the sql prompt.
jg
-- @home.com is bogus. Oracle in the ./ http://developers.slashdot.org/developers/07/07/03/1555209.shtmlReceived on Tue Jul 03 2007 - 15:23:53 CDT
![]() |
![]() |