Automate SQL statements

Hello,
On unix side, I have written below script for taking oracle db backup. But when I tried to execute it - i could not execute the sql statements from unix.
Please suggest
------------------------
$ more bkp.sh
#!/bin/ksh
# make sure database is shutdown cleanly
sqlplus '/ as sysdba' <<eof
{
shutdown immediate;
startup force dba pfile=$ORACLE_HOME/dbs/init.ora;
shutdown immediate;
}
exit;
eof
#Mount the database and start backup
run {
startup mount pfile=$ORACLE_HOME/dbs/init.ora;
}
# Backup datafile, controlfile and archivelogs
rman target=/ << EOF
RUN {
allocate channel ch1 type
disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t';
backup database include current controlfile
tag = '1_daily_backup';
release channel ch1;
}
EXIT;
EOF
# Open the database
run {
alter database open;
}
# Archive all logfiles including current
run {
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
}
# Backup outdated archlogs and delete them
rman target=/ << EOF
RUN {
allocate channel ch1 type
disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t';
backup archivelog
until time 'Sysdate-2' all
delete input;
release channel ch1;
}
EXIT;
EOF
# Backup remaining archlogs
rman target=/ << EOF
RUN {
allocate channel ch1 type
disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t';
backup archivelog all;
release channel ch1;

}
EXIT;
EOF
------------------------

Thank you!

what do you mean could not execute the sql statements. what errors did you receive?

also, please use the code tags(the # icon) around your code.

Ok - I get what was wrong in the script. I was running sql commands within run { } , i have modified and kept all sql statements within sqlplus '/ as sysdba' <<eof
{ ... } and all the rman related commands under rman target=/ << EOF
RUN { ... }

The script looks to be working fine now - Thanks. Except one below error in below piece:
sqlplus '/ as sysdba' <<eof
{
shutdown immediate;
startup mount;
}
exit;
eof

Error is:
SQL> SP2-0042: unknown command "}" - rest of line ignored.

Thanks - The problem is resolved now and I learn that in unix script style - SQL commands dont require parenthesis and will run as below:
sqlplus '/ as sysdba' <<eof
alter database open;
ALTER SYSTEM ARCHIVE LOG CURRENT;
exit;
eof

Thank you for the hints.