oracledba.help
Scripts

DBA Script

<- Scripts

#!/bin/bash
# Purpose: Common include file for parent scripts.
# Version: 2018.10.01

# Oracle
ORACLE_SID="dnaprod1";
ORACLE_BASE="/u01/app/oracle";
ORACLE_HOME="/u01/app/oracle/product/12.1.0.2/db_1";

# Dirs
DIR_LIB="$DIR_SCRIPTS/lib";
DIR_LOGS="$DIR_SCRIPTS/logs";
DIR_OUT="$DIR_SCRIPTS/out";
DIR_TMP="$DIR_SCRIPTS/tmp";
if [[ ! -d $DIR_LIB ]];  then mkdir $DIR_LIB;  fi
if [[ ! -d $DIR_LOGS ]]; then mkdir $DIR_LOGS; fi
if [[ ! -d $DIR_OUT ]];  then mkdir $DIR_OUT;  fi
if [[ ! -d $DIR_TMP ]];  then mkdir $DIR_TMP;  fi

# Misc
MAINT_WINDOW=0;
START_SEC="$SECONDS";
TERM=xterm

#############
# Functions #
###############################################################################
SysVars_show() {
   printf "DIR_SCRIPTS: $DIR_SCRIPTS\n"
   printf "DIR_LIB:     $DIR_LIB\n"
   printf "DIR_LOGS:    $DIR_LOGS\n"
   printf "DIR_OUT:     $DIR_OUT\n"
   printf "DIR_TMP:     $DIR_TMP\n"
   linesep
}

elapse()  { local nSecs=$(($SECONDS - $START_SEC)); local nMins=1;
            if [[ $nSecs -ge 60 ]]; then nMins=$(($nSecs/60)); fi; echo $nMins; }
linesep() { if [[ -z $1 ]]; then printf '%80s\n' | tr ' ' -;
            else printf '%80s\n' | tr ' ' $1; fi; } 
log()     { printf "`now`: $2\n" | tee -a $1; }
now()     { local sNow=$(date "+%Y-%m-%d %H:%M:%S"); echo $sNow; } 
pause()   { read -p "Press [Enter] to continue."; }