Thanks for the question, Ashish.
Asked: April 24, 2001 - 2:45 pm UTC
Last updated: March 02, 2006 - 12:33 pm UTC
Version: Oracle 8.0.4
Viewed 10K+ times! This question is
You Asked
Hello Tom,
I am doing following thing,
sqlplus -s /nolog <<EOF
connect system/$pwd
@hdr
Column tablespace_name format a25 heading "TABLESPACE"
Column initial_extent format 99,999,999 heading "INITIAL"
Column next_extent format 99,999,999 heading "NEXT"
Column min_extents format 99,999,999 heading "MIN"
Column max_extents heading "MAX"
Column CONTENTS format a9 heading "CONTENTS"
TTitle left "***** Database: "dbname", Tablespace Information ( As of: "xdate" ) *****" skip 2
spool temp.txt
select
tablespace_name,
initial_extent,
next_extent,
min_extents,
decode(max_extents,2147483645,'UNLIMITED',max_extents) max_extents,
CONTENTS
from
dba_tablespaces
where tablespace_name=upper('&tbsp');
spool off
clear columns
EOF
But when I ran the script from shell it dosn't wait for the parameter and come out from the shell.
I want to do above query using shell script. Could you suggest me the solution?
Thanks,
Ashish Kher.
and Tom said...
Well, it looks like you are trying to do an "interactive" thing (&tbsp) in a non-interactive environment <<EOF.
Simply change &tbsp into $1 and pass the argument into the script. eg:
$ cat test.csh
#!/bin/csh
sqlplus -s /nolog <<EOF
connect /
Column tablespace_name format a25 heading "TABLESPACE"
Column initial_extent format 99,999,999 heading "INITIAL"
Column next_extent format 99,999,999 heading "NEXT"
Column min_extents format 99,999,999 heading "MIN"
Column max_extents heading "MAX"
Column CONTENTS format a9 heading "CONTENTS"
spool temp.txt
select
tablespace_name,
initial_extent,
next_extent,
min_extents,
decode(max_extents,2147483645,'UNLIMITED',max_extents) max_extents,
CONTENTS
from
dba_tablespaces
where tablespace_name=upper('$1');
spool off
clear columns
EOF
$ ./test.csh system
Connected.
TABLESPACE INITIAL NEXT MIN
------------------------- ----------- ----------- -----------
MAX CONTENTS
---------------------------------------- ---------
SYSTEM 16,384 16,384 1
505 PERMANENT
Rating
(5 ratings)
Is this answer out of date? If it is, please let us know via a Comment