v$ tables not recognized in a sql statement of a shell script
Try: sqlplus -S / as sysdba &lt;&lt;'EOFILE' ... 

Putting quotes tells the shell to not interpret the contents of the here document: it does not try to interpret $XXX in the here document as a shell variable.