Hi,
Note: I'm a beginner in scripting
I'm working on creating a kornshell script to automate copy back procedure for our oracle SAP databases from PROD to Dev/Test environment. This is just the starting point, what I'm having trouble with is exiting from sql prompt after running the query which generates controlfile to a specified path. On line 4 if I put the (exit) statement, instead of disconnecting from database this statement would cause exit from script. I do not want to exit from script at this point yet, instead I would like to switch to OS prompt and have the commands I have written run against the controlfile in order to modify it as per requirement.
MY Script
#!/usr/bin/ksh
#Create and Modify Controlfile
1. sqlplus / as sysdba <<EOF> sap_copyback.log
2. Alter database backup controlfile to trace as '/dbashare/ccf.sql' REUSE;
3. whenever sqlerror exit sql.sqlcode;
4. exit;
5. cd /dbashare
6. chmod 766 ccf.sql
7. echo "Enter Source SID: "
8. read SourceSID
9. echo "Enter Target SID: "
10. read TargetSID
11. sed '%s/${SourceSID}/${TargetSID}/g' ccf.sql > ccf.sql.new && mv ccf.sql.new ccf.sql
12. sed '1,/#2/d' ccf.sql > ccf.sql.new && mv ccf.sql.new ccf.sql
13. sed -ne '/ALTER TABLESPACE PSAPTEMP/ p' ccf.sql > addtempdataFile.sql
14. sed -ne '/AUTOEXTEND/ p' ccf.sql >> addtempdataFile.sql
15. sed '/Commands to/,$d' ccf.sql > ccf.sql.new && mv ccf.sql.new ccf.sql
16. cd /dbashare
#Copy backup file and extract information from this file about archive logs needed for database recovery
17. find /oracle/$ORACLE_SID/sapbackup -name '*.anf' -mtime -2 -exec cp {} /dbashare \;
Any help is appreciated,
Shahid