Wednesday, 20 November 2013

Electrical Resistance Calculator

for z in "Electrical Resistance Calc"
do
echo -e "\n\nEnter ressistor value 1: "
read R1
echo -e "Enter ressistor value 2: "
read R2
VALA=`echo ${R1}*${R2} | bc -l`
VALB=`echo ${R1}+${R2} | bc -l`
VALC=`echo "scale=2;${VALA}/${VALB}" | bc -l`
echo -e "Total resistance in series is: ${VALB}"
echo -e "Total resistance in parallel is: ${VALC}\n\n"
done

Friday, 15 November 2013

Build scripts 1 - directories


for z in SED
do
echo -e "\nEnter Primary database name: "
read DB1
echo -e "\nEnter Standby database name: "
read DB2
for DB_NAME in ${DB1} ${DB2}
do
cd ~
mkdir -p admin/${DB_NAME}/
cd admin/${DB_NAME}/
mkdir -p diag pfile spfile exp audit scripts logs
done
cd ~
du -ah admin/
done

Monday, 11 November 2013

Dates of Week for remaining current year - Run as "bash sed_date_checker.bsh"

#!/bin/bash
# function weekof()
weekof()
{
    local week=$1 year=$2
    local week_num_of_Mon_1 week_day_of_Mon_1
    local first_Mon
    local date_fmt="+%a %b %d %Y"
    local mon sun

    week_num_of_Mon_1=$(date -d $year-01-01 +%W)
    week_day_of_Mon_1=$(date -d $year-01-01 +%u)

    if ((week_num_of_Mon_1)); then
        first_Mon=$year-01-01
    else
        first_Mon=$year-01-$((01 + (7 - week_day_of_Mon_1 + 1) ))
    fi

    mon=$(date -d "$first_Mon +$((week - 1)) week" "$date_fmt")
    sun=$(date -d "$first_Mon +$((week - 1)) week + 6 day" "$date_fmt")
    # echo "\"$mon\" - \"$sun\""
    echo -e "\n\nFor week no: ${week}"
    echo -e "\t""\"$mon\" - \"$sun\""
    # echo -e "\n"
}

for z in SED
do
CW=`date '+%W'`
YR=`date '+%Y'`
MW=52
CNT=${CW}
MAX=`expr ${MW} + 1`
while [ ${CNT} -lt ${MAX} ]
do
# echo $CNT
weekof ${CNT} ${YR}
CNT=`expr ${CNT} + 1`
done
echo -e "\n"
done

Bash script - Week of Year

function weekof()
{
    local week=$1 year=$2
    local week_num_of_Mon_1 week_day_of_Mon_1
    local first_Mon
    local date_fmt="+%a %b %d %Y"
    local mon sun

    week_num_of_Mon_1=$(date -d $year-01-01 +%W)
    week_day_of_Mon_1=$(date -d $year-01-01 +%u)

    if ((week_num_of_Mon_1)); then
        first_Mon=$year-01-01
    else
        first_Mon=$year-01-$((01 + (7 - week_day_of_Mon_1 + 1) ))
    fi

    mon=$(date -d "$first_Mon +$((week - 1)) week" "$date_fmt")
    sun=$(date -d "$first_Mon +$((week - 1)) week + 6 day" "$date_fmt")
    # echo "\"$mon\" - \"$sun\""
    echo -e "\n\nFor week no: ${week}"
    echo -e "\t""\"$mon\" - \"$sun\""
    echo -e "\n\n"
}
weekof $1 $2
#
# Run as  bash sed_dt_test.bsh 32 2013
#

Wednesday, 6 November 2013

ORA-15186: ASMLIB error function

########################################
#
#
#  ORA-15186: ASMLIB error function = [asm_open], error = [1], mesg = [Operation not permitted]
#
#
#  Thanks to: arul selvaraj
#  http://arulselvaraj.blogspot.co.uk/2011/02/ora-15186-asmlib-error-function-asmopen.html
#
#
########################################


for i in /etc/sysconfig/oracleasm
do
ls -al ${i} | grep "^l"
if [ $? != 0 ]
then
 echo -e "\nIssue with file ${i}- should be a link to oracleasm-_dev_oracleasm\n\n"
else
 echo -e "Correct - file is a link"
 ls -al ${i}
 SO=`grep ORACLEASM_SCANORDER /etc/sysconfig/oracleasm-_dev_oracleasm`
 echo -e "\nScan order - ${SO}"
 echo -e "\n\n"
fi
done