Seek help on shell script syntax errors

I want to delete archivelog files that has been archived and applied from primary database
to standby database. This piece of script is working in Linux server. However, I copy it to
Unix server with tiny modification. It won't work and generate the error message. I have checked
code carefullt and cannot find where is the problem. I post script here to seek advice.

  1. Following is the part of script
#!/bin/sh
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin
export PATH
RMAN=$ORACLE_HOME/bin/rman
export MAXLOGSEQ=`sqlplus -s << EOF
/as sysdba
@/oracle10/scripts/rman/check_maxseq.sql    ---- this sql script to egt maximun archivelog sequence number.
EOF`
echo $MAXLOGSEQ

TARGET_CONNECT_STR="catalog rman/$RMAN_PW@catalog_db target /"

CMD_STR="
$RMAN $TARGET_CONNECT_STR << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE ${MAXLOGSEQ} ; 
 }
EOF
"
# Initiate the command string
 
if [ "$CUSER" = "root" ]
then
    su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
else
    /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
fi

  1. This is error message. Please advise which part of syntax is wrong because the same script
    has been run on Linux for a long time.
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Aug 1 14:08:55 2011

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: EXPRD (DBID=4037707233, not open) connected to recovery catalog database

RMAN> 2> 3> 4> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "integer"RMAN-01007: at line 4 column 43 file: standard input

RMAN> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: ";"RMAN-01008: the bad identifier was: ch00
RMAN-01007: at line 1 column 17 file: standard input

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog,
change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, 
flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, 
reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 1 column 21 file: standard input

RMAN> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "}": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, 
connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, 
{, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync,
rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 1 column 1 file: standard input

RMAN> 

Recovery Manager complete.

What particular Unix platform are you on?

I doubt that the problem is in the script itself, as you mentioned it has been running for a long time, so assuming no one has changed it, the problem is actually in the database, considering also the "RMAN-01007", which has a various causes, like the DB instance being opened at the same time from another place / application.

Sorry for not being able to help more, just general guidelines and thoughts, I'm out of the office, so no access to Oracle.

I'm pretty sure the problem is in the passwd database. The login shell
for the oracle user is set to the oracle executable
Path instead of just the login shell. Thus, oracle is trying to interpret the initial
Script intended to be run under the shell.

If I'm right ("getent passwd oracle" will tell you) post back here and we will discuss fixes (other than changing the login shell)

Thanks so much for your advice. My Unix platform is HP UNIX 64 bit. I am runing this shell script on standby database to delete applied archivelog files from primary and standby both.

I tried to use getent command. But it seems not exist on HP UNIX machine. So I tried to use pwget and grget as this:

> pwget -u /etc/passwd

I got

>root:x:0:3:System Administrator:/home/root:/sbin/sh

Please advise.

---------- Post updated at 11:19 AM ---------- Previous update was at 11:05 AM ----------

On the Linux box, I run getent

>getent passwd, Then I got

>oracle:x:501:501:Oracle Administrator:/home/oracle:/bin/bash

---------- Post updated at 11:48 AM ---------- Previous update was at 11:19 AM ----------

I comment out "PATH=$PATH:$ORACLE_HOME/bin export PATH", then I run again. I got this

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Aug 2 11:29:00 2011

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: EXPRD (DBID=4037707233, not open) connected to recovery catalog database

RMAN> 2> 3> 4> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "integer"
RMAN-01007: at line 4 column 43 file: standard input

RMAN> 2> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "}": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 2 column 1 file: standard input

RMAN> 

Recovery Manager complete.

You need to find out the login shell of the oracle user. You ran pwget, but with the wrong arguments. According to online resources, you should run:

pwget -u oracle

I run

>pwget -u oracle

I got

>root:x:0:3:System Administrator:/home/root:/sbin/sh

We login UNIX server by individual username/passwd. Then su to oracle user. We use oracle user to do database works.

I dont know hp ux, so just Find out the login shell for oracle somehow. Grep the passwd file for instance

You might try the "-n" switch.
off-course the alternate of grep oracle /etc/passwd is always there.

e.g.

$ pwget -n testuser
testuser:*:112:3019:Test User:/use/home/test1:/usr/local/bin/bash
$ 

man pwget for hp-ux shows that "-u" retrieves based on UID

           -u uid         Output the first entry that matches uid using
                          getpwuid() (see getpwent(3C)).

           -n name        Output the first entry that matches name using
                          getpwnam() (see getpwent(3C)).
$ pwget -u 112
testuser:*:112:3019:Test User:/use/home/test1:/usr/local/bin/bash
$