Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture command line output to a file

Status
Not open for further replies.

aking

Technical User
Aug 11, 2002
112
GB
Hi, I'm trying to master command line Oracle:
Can anyone tell me why the first spool is successful but the second one isn't?

SQL> Spool text1
SQL> select * from dba_segments where tablespace_name = 'PRODUCTION';

SQL> Spool text2
SQL> select tablespace_name, segment_name, bytes, blocks, extents from dba_segments where tablespace_name = 'PRODUCTION';

text1.lst is a file containing all the contents of dba_segments for the Production tablespace as i would expect.
text2.lst is an empty file, but there is output on the screen - so i'm copying and pasting it. But obviously this method has limitations and it would be much better to be able to capture it straight to file.


 
Try a spool off after the first select, and a spool off after the second.

Regards

T
 
You don't need a "spool off" after the first select - your "Spool text2" command implicitly closes the spooling to text1. But you do need a "spool off" after the second select. The reason you are seeing an empty text2.lst file is that the output of your select is so short that it hasn't filled up the file's write buffer. A "spool off" will flush the buffer to file and allow you see your output.
 
Thanks a lot guys - spool off did the trick instantly.
That one came at the end of a long day and totally floored me! (Mind you oracle command line usually does anyway sooner or later ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top