![]() |
|
|
|
|
|||||||
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| server seek internet | ariec | AIX | 0 | 06-05-2008 12:20 AM |
| seek-1f42 1.46 (Default branch) | iBot | Software Releases - RSS News | 0 | 03-19-2008 04:30 PM |
| seek-h262 4.76 (Default branch) | iBot | Software Releases - RSS News | 0 | 12-24-2007 11:12 AM |
| Solaris 10 Tutor | kress2m1 | SUN Solaris | 1 | 10-27-2007 06:38 AM |
| Why script For...Loop doesn't work. Seek help | duke0001 | UNIX for Dummies Questions & Answers | 3 | 10-16-2006 01:22 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 09:28 AM. |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
| Thread Tools | |
| Display Modes | |
|
|