Here is a shell script to run SQL commands and spool only the output (Not the SQL Command or any other lines from your script).
(** The trick is to use "sqlplus -S" option)
$ cat test01.sh
sqlplus -S /nolog << EOF
CONNECT system/xxxxx@mydb
set trim on trims on
set echo off
set feedback off
set define off
spool test01.log
SELECT SUM(PERCENT_SPACE_USED) USED_PERCENT FROM V\$FLASH_RECOVERY_AREA_USAGE HAVING SUM(PERCENT_SPACE_USED) > 10;
spool off
exit;
EOF
$ ./test01.sh
USED_PERCENT
------------
20.69
$ cat test01.log
USED_PERCENT
------------
20.69
$
(** The trick is to use "sqlplus -S" option)
$ cat test01.sh
sqlplus -S /nolog << EOF
CONNECT system/xxxxx@mydb
set trim on trims on
set echo off
set feedback off
set define off
spool test01.log
SELECT SUM(PERCENT_SPACE_USED) USED_PERCENT FROM V\$FLASH_RECOVERY_AREA_USAGE HAVING SUM(PERCENT_SPACE_USED) > 10;
spool off
exit;
EOF
$ ./test01.sh
USED_PERCENT
------------
20.69
$ cat test01.log
USED_PERCENT
------------
20.69
$
No comments:
Post a Comment