Seek help on shell script syntax errors

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Seek help on shell script syntax errors
# 1  
Old 08-02-2011
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

Code:
#!/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

2. 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.

Code:
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.


Last edited by pludi; 08-02-2011 at 05:27 AM..
# 2  
Old 08-02-2011
What particular Unix platform are you on?
# 3  
Old 08-02-2011
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.
# 4  
Old 08-02-2011
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)
# 5  
Old 08-02-2011
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:

Code:
> pwget -u /etc/passwd

I got

Code:
>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

Code:
>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

Code:
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.


Last edited by pludi; 08-02-2011 at 03:41 PM..
# 6  
Old 08-02-2011
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:
Code:
pwget -u oracle

# 7  
Old 08-02-2011
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with shell scrip syntax errors

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This script will analyse the channels.txt e registrations.txt and it will allow to mage the channels and the... (9 Replies)
Discussion started by: Demas
9 Replies

2. Shell Programming and Scripting

Converting from Linux bash (GNU) to Solaris script syntax errors

Original script written on CentOS 6.3 with GNU bash 4.1.2 Destination system is Solaris 9 with GNU bash 2.05 (not changeable by me) I have a script written on the linux side but now we need to provide a version to another site that "doesn't like linux". I've been going through changing the ] or... (13 Replies)
Discussion started by: oly_r
13 Replies

3. Shell Programming and Scripting

How to turn off ora errors in shell script?

I have a shell script which select total count from a table and use its value in a if condition like below connect_string="username/password@tnsname" tot=`sqlplus -s $connect_string << EOF set echo off set feedback off set head off select count(*) from test_table; EOF ` if then echo... (2 Replies)
Discussion started by: vel4ever
2 Replies

4. Shell Programming and Scripting

shell script for conky getting errors....

So I have a script that does a greater than or less than with a variable. My problem is that when I checked the script from the command line I was getting this error.. I am not really familiar with shell scripting. I am trying to get this script to work with conky so that it will do the... (8 Replies)
Discussion started by: krisdeniseriley
8 Replies

5. Shell Programming and Scripting

line count with if /else - syntax errors

this is the script: ps -ef|grep "x_jobstat 10 v001" > jobstatv001.txt ps -ef |grep "x_jobserver 10 v001" >> jobstatv001.txt #Sample text - each line preceded by 4 spaces # root 133064 102986 0 08:49:28 pts/6 0:00 grep x_jobstat 10 v001 # root 137550 1 0 Nov 08 - 0:28... (6 Replies)
Discussion started by: kwalkner
6 Replies

6. Shell Programming and Scripting

PERL Syntax Errors

Hi, I am a newbie to PERL and working on a script. When running it I get a lot of compilation errors. The actual command in the program (which is within a case structure) is given below # This gives the actual count of inquires from a log file (It works fine when I type this on the... (2 Replies)
Discussion started by: nurani
2 Replies

7. Shell Programming and Scripting

perl version for syntax errors

All, Does it matter what perl verios your running when you get syntax errors? on version 5.6.1 the code works fine, but on 5.8.0 the code gets errors? #!/usr/bin/perl #use strict; #use warnings; my $mess = 'messages'; my $mess1 = 'messages.1'; my $mess2 = 'messages.2'; my... (13 Replies)
Discussion started by: bigben1220
13 Replies

8. Shell Programming and Scripting

Help with shell script errors

hey watsup guys i am new in the shell script world. so i need help fom you guys, i have written these two codes and they both give the same errors( expr : syntax error). Code 1 : #! /bin/sh # count1 appends an increment to a file 200 times # note that a file called numbers must be... (5 Replies)
Discussion started by: surubi_abada
5 Replies

9. Shell Programming and Scripting

Parse for errors shell script

All, I have a shell script which parses the /var/adm/messages file for errors every 15 minutes as a cron job. The script runs at 01, 16, 31, and 46 minutes every hour. The problem is if the error is encountered any time during the beginning of hour I can get paged three times. I would like to... (2 Replies)
Discussion started by: bubba112557
2 Replies

10. Shell Programming and Scripting

AWK Syntax errors :/

I recently started as an intern and my manager wanted to see how well I would handle Korn Bourne shell scripting without any prior experience, I have prior programming experience but I keep running into syntax errors with AWK. Please take a look at my simple code and tell me what stupid mistake... (6 Replies)
Discussion started by: yongho
6 Replies
Login or Register to Ask a Question