Database Reference
In-Depth Information
You can find more information about this process at http://www.tldp.org/LDP/abs/html/here-docs.html
Each EM CLI command runs on a stand-alone statement, so a subshell is not required when called by your shell
script. In its place, you should use shell script functions when a series of related CLI commands needs to be executed
together.
Shell Script Functions
Shell function syntax is quite simple. Just follow these steps:
1.
Using the keyword function, give the function a name followed by an opening brace.
Braces are the curly brackets { }, and brackets are these angular objects: [ ].
2.
Include the shell commands to be executed.
3.
Add a closing brace.
In the following example, the contents of several directories are copied to a backup destination. The code for creating
the file list and the actions required to move the files could be repeated for each directory. Instead, the recurring tasks
are performed by the same block of code, which is called by the function name CopyFiles . Common supplemental
tasks, such as compressing and chmodding the files, can be added so as to function for single-source editing.
Variables, such as SOURCE_DIR , TARGET_DIR , and WORKFILE , are passed to the function at run-time. Dependent
variables, such as SOURCE_FILE and TARGET_FILE , are populated at run-time for each directory:
# ----------------------------------------------------
# Functions
# ----------------------------------------------------
function CopyFiles {
cd $SOURCE_DIR
ls -l | grep -i $ORACLE_SID >$WORKFILE
for thisFILE in `cat $WORKFILE`; do
SOURCE_FILE=$SOURCE_DIR/$thisFILE
TARGET_FILE=$TARGET_DIR/$thisFILE
cp -f $SOURCE_FILE $TARGET_FILE
done
rm -f $WORKFILE
}
# ----------------------------------------------------
# Run-time Procedure
# ----------------------------------------------------
SOURCE_DIR=/gold_scripts/rman
TARGET_DIR=/test_scripts/rman
CopyFiles
SOURCE_DIR=/gold_scripts/security
TARGET_DIR=/test_scripts/security
CopyFiles
 
Search WWH ::




Custom Search