1

spooltest.sql:

SPOOL test.log
CLEAR SCREEN
SET VERIFY OFF
PROMPT Queries will appear in spool
select sys_context('USERENV', 'INSTANCE_NAME') from dual;
PROMPT Output from the HOST command will not
HOST ECHO %COMPUTERNAME%
SPOOL OFF

sqlplus output:

Queries will appear in spool

SYS_CONTEXT('USERENV','INSTANCE_NAME')
---------------------------------------------------

wibble

Output from the HOST command will not
AWESOMESERVERNAME

SQL>

test.log:

Queries will appear in spool

SYS_CONTEXT('USERENV','INSTANCE_NAME')                                          
--------------------------------------------------------------------------------
wibble

Output from the HOST command will not

If it's not possible to capture HOST output, can someone please suggest a workaround.

1
  • you mean just capture the host variable output ? and eliminate the queries ?
    – Up_One
    Mar 13, 2014 at 15:37

1 Answer 1

3

Yeah spool only captures output from SQLPlus itself. Try this - Before invoking your OS command, turn spooling off. Then pipe the output to the end of the file. Then you can use spool append to start spooling from where you left off again:

spool test.log
select blah from blah;
spool off
!echo %COMPUTERNAME% >> test.log
spool test.log append 
select * from argh;
1
  • Perfect, although on reflection I think I might be misusing spool.
    – booyaa
    Mar 13, 2014 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.