Posts

Showing posts with the label bash

Coloring alert.log output via tail and less

Image
Making my day to day job easier and convenient I like having some utilities and some aliases. We, the DBAs nation, have a need to look at the alert.log file frequently. So basically, I did the following: - Created a script to tail my alert.log file. - Colored the important words. - Added an alias to that script $ vi tail_alert.sh #!/bin/bash export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source ${SCRIPT_DIR}/platform.env ECHO_RED="\E[1;40;31m" ECHO_STD="\E[1;40;37m" LIGHT_RED=`echo -e '\033[1;40m\033[1;31m'` RED=`echo -e '\033[1;40m\033[0;31m'` LIGHT_PURPLE=`echo -e '\033[1;40m\033[0;35m'` GREEN=`echo -e '\033[1;40m\033[32m'` NORMAL=`echo -e '\033[0m'` if [ "$1" = "" ] then     ALERT_FILE=${ORACLE_BASE}/diag/${DIR_TYPE}/${ORACLE_UNQNAME,,}/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log     if [ ! -s ${ALERT_FILE} ]     then...

DBA Scripts coding considerations for best compatibility to any platform

Image
Did you find yourself trying to convert your DBA scripts to work on other OS or UNIX flavors ? This is a typical issue DBAs cope with, the solutions can be: Each system has its own best scripting code (PowerShell for windows, bash for Linux), let's keep some versions of the same code. Write the code in a common language for all systems Shell : In the past I used the old Posix shell (sh) which exited in all Unix systems. These days I use bash as is very common.  Perl : Oracle installation already has its own Perl, no need to install it. Java : Oracle installation already has its own java, no need to install it. Python : Python should be installed, but the libraries that can be used are huge, and you can write shorter code. Write in sql/plsql as much as you can, the external code will be minimal (cmd / sh). Work remotely from your convenient operating system, using your scripts written in the language you master. Use a few macros injected to your terminal. Why...