Seek UNIX script tutor and help | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Seek UNIX script tutor and help

UNIX for Advanced & Expert Users


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-08-2008
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Seek UNIX script tutor and help

I am new to UNIX shell script programming. I have coded one korn shell script used on solaris 10 for Oracle database rman cold backup. The first part of script is working. But only following part is not working. Please help me to point out the problem and errors in my code. Thanks a lot.

# the first part has been omitted.

# Started to shutdown database and startup database mount for cold backup .

${ORACLE_HOME}/bin/sqlplus -s << EOF
conn / as sysdba
shutdown immediate;

${ORACLE_HOME}/bin/sqlplus -s << EOF
conn / as sysdba
startup mount;

# The above part works, then script stop here.


exit

rman NOCATALOG <<EOF
CONNECT TARGET SYS/$SYS_PASSWORD@$ORACLE_SID
if [ $? = 0 -o $? = 2 ]
then date +"%D %T: backup process started." >> pdedev$BACKUP_DAY.LOG
else date +"%D %T: Error start rman to do backup." >> pdedev$BACKUP_DAY.LOG
exit 1
fi
RUN
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK
FORMAT = '$BACKUP_FOLDER/%d_DB_%u_%s_%p' MAXPIECESIZE 5G;
BACKUP DATABASE PLUS ARCHIVELOG DELETE ALL INPUT;
RELEASE CHANNEL ch1;

SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
}
if [$? = 0]
then date +"%D %T: Rman backup successful." >> $BACKUP_DAY.LOG
echo "" >> $BACKUP_DAY.LOG
else date +"%D %T: Rman backup not successful." >> $BACKUP_DAY.LOG
date +"%D %T: Exiting script." >> $BACKUP_DAY.LOG
exit 1
fi

# Open database

${ORACLE_HOME}/bin/sqlplus -s << EOF
conn / as sysdba
alter database open;
echo " database $ORACLE_SID is up running." >> $BACKUP_DAY.LOG

exit
EOF

Last edited by duke0001; 05-09-2008 at 12:28 PM..
Sponsored Links
    #2  
Old 05-12-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks: 0
Thanked 10 Times in 8 Posts
You are using <<EOF "here documents" without a closing EOF terminator. The whole remainder of the script gets passed to SQL (which ignores it, if it doesn't outright choke on it).

The "exit" is apparently not really supposed to be there? If it is, that's where the script terminates.

The "here document" syntax is a bit hard to grok until you get the hang of it. Maybe a few examples can help.


Code:
cat <<END_OF_FIRST_HERE_DOCUMENT

This will be copied to standard output
including this part which really looks a lot like a shell script
#!/bin/sh
echo frnod
exit 255
This is all just text as far as the shell is concerned,
so we don't care even that this looks like an unterminated
single-quoted string (because of the single quote between "don" and "t").
END_OF_FIRST_HERE_DOCUMENT

echo Script execution continues here

cat <<!
Another here document
you can use almost anything as a terminator
!

echo Back to the studio
exit 0

Sponsored Links
    #3  
Old 05-12-2008
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Era:

Thanks for your help. I will try again.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Seek help on shell script syntax errors duke0001 Emergency UNIX and Linux Support 8 08-03-2011 03:06 AM
Seek help configuring Sendmail 8.14.4 Unix raecampus UNIX for Dummies Questions & Answers 0 01-22-2011 12:12 PM
dd seek problem silvermoon UNIX for Advanced & Expert Users 6 08-31-2008 03:35 PM
Solaris 10 Tutor kress2m1 Solaris 1 10-27-2007 09:38 AM
Why script For...Loop doesn't work. Seek help duke0001 UNIX for Dummies Questions & Answers 3 10-16-2006 04:22 PM



All times are GMT -4. The time now is 09:40 AM.