redirecting SQL output from within a shell script

Hi all

I would like to open a SQL session from within a shell script and then redirect the output of the SQL command to a file.

e.g.

#!/bin/bash

sqlplus "/ as sysdba" <<EOF

@$HOME/recovery_space.sql

EOF

I want to redirect the output of the SQL command to a temp file, because further down in the shell script I want to mail the contents of the temp file to the appropriate recipients.

Does anyone know how I can accomplish this?

sqlplus '/ as sysdba' <<EOF > outfile

or use the sqlplus spool command.

Thanks mate. I've decided to use the spool funcion of SQL.