This also works fine for me:


export SQLPLUS=$ORACLE_HOME/bin/sqlplus
$SQLPLUS -s /@dbname << EOF
select count(*) from user_objects;
exit
EOF