#! /bin/sh
#########################find some specified string in files############################
fs()
{
if [ $# -lt 1 ];then
echo "#####################################find string in file USAGE##############################"
echo "Usage: if you find file in the current directroy ---------------- ff FILE_NAME"
echo "if you want to find error/exception string for the specific package or server log ------------- fs PACKAGE_NAME STRING1 STRING2 ....."
echo "for example: --------------------- for gollfDmain ---------------------------"
echo "-------------fs ds error exception-----------------"
echo "-------------fs server error exception-------------"
echo "-------------fs node1 error------------------------"
echo "--------------------------------------------------------------"
echo "--------------for gollfirmDomain:------------------"
echo "-------------fs ids error exception-----------------"
echo "-------------fs iserver error exception-------------"
echo "-------------fs inode1 error------------------------"
return
fi
PACKAGE_LOG=$1
case "$PACKAGE_LOG" in
"a")
OBJECT="a.log" ;;
"b")
OBJECT="b.log" ;;
"c")
OBJECT="c.log" ;;
*)
OBJECT=$PACKAGE_LOG
;;
esac
shift
until [ $# -eq 0 ];do
SEARCH_STRING=$1
echo "SEARCH_STRING is $SEARCH_STRING"
find $OBJECT -exec grep -i "$SEARCH_STRING" '{}' /dev/null \;
shift
done
}
##################################find a file###########################################
ff()
{
if [ $# -lt 1 ];then
echo "#####################################find file USAGE##############################"
echo "Usage: if you find file in the current directroy ---------------- ff FILE_NAME"
echo "if you want to fine file in the specific directory ---------------- ff DIR_FOLDER FILE_NAME"
return
elif [ $# -eq 1 ];then
FILE_NAME=$1
DIR="."
elif [ $# -eq 2 ];then
DIR=$1
FILE_NAME=$2
fi
find $DIR -type f -name "$FILE_NAME"
}
################################check log ##############################################
checklog()
{
if [ $# -lt 1 ];then
echo "#####################################checklog USAGE##############################"
echo "Usage: checklog APPLICATION_NAME PACKAGE_NAME LINE_NUMBER"
return
elif [ $# -eq 3 ];then
APP_NAME=$1
PACKAGE=$2
LINE=$3
fi
if [ $APP_NAME = "a" ];then
cd /aa
case "$PACKAGE" in
"a")
tail -${LINE}f a.log ;;
"b")
tail -${LINE}f b.log ;;
"c")
tail -${LINE}f c.log ;;
*)
echo "invalid package name!!!!"
;;
esac
elif [ $APP_NAME = "b" ];then
cd /bb
case "$PACKAGE" in
"a")
tail -${LINE}f a.log ;;
"b")
tail -${LINE}f b.log ;;
"c")
tail -${LINE}f c.log ;;
*)
echo "invalid package name!!!!"
;;
esac
fi
}
###########################connect DB using sqlplus###########################################################3
conndb()
{
if [ $# -lt 1 ];then
echo "#####################################conndb USAGE##############################"
echo "Usage: conn DB_NAME"
return
fi
SERVER_NAME=$1
case "$SERVER_NAME" in
"aDB")
CONNECTION="username1/pwd1@serverName1:port1/dbName1" ;;
"bDB")
CONNECTION="username2/pwd2@serverName2:port2/dbName2" ;;
*)
echo "invalid DB name"
;;
esac
echo "enter connection....."
sqlplus $CONNECTION
}
#######################################check out code#######################################################
checkout()
{
if [ $# -lt 1 ];then
echo "#####################################checkout USAGE##############################"
echo "Usage: check out code from trunk ----------------- checkout MODULE_NAME"
echo "check out code from branch ----------------- checkout BRANCH_NAME MODULE_NAME"
return
fi
BRANCH=""
# check args
if [ $# -eq 2 ]
then
BRANCH="-r $1"
case "$2" in
"A")
MODULE="AA/BB/CC" ;;
"B")
MODULE="BB/CC/DD" ;;
*)
echo "invalid package name"
exit 1
;;
esac
else
case "$1" in
"A")
MODULE="AA/BB/CC" ;;
"B")
MODULE="BB/CC/DD" ;;
*)
echo "invalid package name"
;;
esac
fi
USERID=`whoami`
CVS=/xenv/cvs/X/1.11.22/bin/cvs
CVSROOT=":ServerType:USERID@servername:port/CVSRepository"
export CVSROOT
WORKING_DIR=`pwd`
COMMON="aa/common"
cd $WORKING_DIR
echo "Removing old files..."
rm -rf $COMMON
rm -rf $MODULE
if [ $BRANCH ];then
echo "Checking out $MODULE from branch $BRANCH........"
else
echo "Checking out $MODULE from head"
fi
if [ $MODULE = "gollf" ];then
${CVS} -Q checkout -P $BRANCH $MODULE
else
${CVS} -Q checkout -P $BRANCH $COMMON
${CVS} -Q checkout -P $BRANCH $MODULE
fi
cd $MODULE
}
###################################create branch based on a tag##############################################
branch()
{
if [ $# -lt 1 ];then
echo "#####################################branch USAGE##############################"
echo "Usage: branch BRANCH_NAME"
return
fi
BRANCH_NAME=$1
CVSROOT=":ServerType:USERID@servername:port/CVSRepository"
export CVSROOT
cvs rtag Root_${BRANCH_NAME} Project_Name
cvs rtag -b -r Root_${BRANCH_NAME} ${BRANCH_NAME} Project_Name
}
#########################find some specified string in files############################
fs()
{
if [ $# -lt 1 ];then
echo "#####################################find string in file USAGE##############################"
echo "Usage: if you find file in the current directroy ---------------- ff FILE_NAME"
echo "if you want to find error/exception string for the specific package or server log ------------- fs PACKAGE_NAME STRING1 STRING2 ....."
echo "for example: --------------------- for gollfDmain ---------------------------"
echo "-------------fs ds error exception-----------------"
echo "-------------fs server error exception-------------"
echo "-------------fs node1 error------------------------"
echo "--------------------------------------------------------------"
echo "--------------for gollfirmDomain:------------------"
echo "-------------fs ids error exception-----------------"
echo "-------------fs iserver error exception-------------"
echo "-------------fs inode1 error------------------------"
return
fi
PACKAGE_LOG=$1
case "$PACKAGE_LOG" in
"a")
OBJECT="a.log" ;;
"b")
OBJECT="b.log" ;;
"c")
OBJECT="c.log" ;;
*)
OBJECT=$PACKAGE_LOG
;;
esac
shift
until [ $# -eq 0 ];do
SEARCH_STRING=$1
echo "SEARCH_STRING is $SEARCH_STRING"
find $OBJECT -exec grep -i "$SEARCH_STRING" '{}' /dev/null \;
shift
done
}
##################################find a file###########################################
ff()
{
if [ $# -lt 1 ];then
echo "#####################################find file USAGE##############################"
echo "Usage: if you find file in the current directroy ---------------- ff FILE_NAME"
echo "if you want to fine file in the specific directory ---------------- ff DIR_FOLDER FILE_NAME"
return
elif [ $# -eq 1 ];then
FILE_NAME=$1
DIR="."
elif [ $# -eq 2 ];then
DIR=$1
FILE_NAME=$2
fi
find $DIR -type f -name "$FILE_NAME"
}
################################check log ##############################################
checklog()
{
if [ $# -lt 1 ];then
echo "#####################################checklog USAGE##############################"
echo "Usage: checklog APPLICATION_NAME PACKAGE_NAME LINE_NUMBER"
return
elif [ $# -eq 3 ];then
APP_NAME=$1
PACKAGE=$2
LINE=$3
fi
if [ $APP_NAME = "a" ];then
cd /aa
case "$PACKAGE" in
"a")
tail -${LINE}f a.log ;;
"b")
tail -${LINE}f b.log ;;
"c")
tail -${LINE}f c.log ;;
*)
echo "invalid package name!!!!"
;;
esac
elif [ $APP_NAME = "b" ];then
cd /bb
case "$PACKAGE" in
"a")
tail -${LINE}f a.log ;;
"b")
tail -${LINE}f b.log ;;
"c")
tail -${LINE}f c.log ;;
*)
echo "invalid package name!!!!"
;;
esac
fi
}
###########################connect DB using sqlplus###########################################################3
conndb()
{
if [ $# -lt 1 ];then
echo "#####################################conndb USAGE##############################"
echo "Usage: conn DB_NAME"
return
fi
SERVER_NAME=$1
case "$SERVER_NAME" in
"aDB")
CONNECTION="username1/pwd1@serverName1:port1/dbName1" ;;
"bDB")
CONNECTION="username2/pwd2@serverName2:port2/dbName2" ;;
*)
echo "invalid DB name"
;;
esac
echo "enter connection....."
sqlplus $CONNECTION
}
#######################################check out code#######################################################
checkout()
{
if [ $# -lt 1 ];then
echo "#####################################checkout USAGE##############################"
echo "Usage: check out code from trunk ----------------- checkout MODULE_NAME"
echo "check out code from branch ----------------- checkout BRANCH_NAME MODULE_NAME"
return
fi
BRANCH=""
# check args
if [ $# -eq 2 ]
then
BRANCH="-r $1"
case "$2" in
"A")
MODULE="AA/BB/CC" ;;
"B")
MODULE="BB/CC/DD" ;;
*)
echo "invalid package name"
exit 1
;;
esac
else
case "$1" in
"A")
MODULE="AA/BB/CC" ;;
"B")
MODULE="BB/CC/DD" ;;
*)
echo "invalid package name"
;;
esac
fi
USERID=`whoami`
CVS=/xenv/cvs/X/1.11.22/bin/cvs
CVSROOT=":ServerType:USERID@servername:port/CVSRepository"
export CVSROOT
WORKING_DIR=`pwd`
COMMON="aa/common"
cd $WORKING_DIR
echo "Removing old files..."
rm -rf $COMMON
rm -rf $MODULE
if [ $BRANCH ];then
echo "Checking out $MODULE from branch $BRANCH........"
else
echo "Checking out $MODULE from head"
fi
if [ $MODULE = "gollf" ];then
${CVS} -Q checkout -P $BRANCH $MODULE
else
${CVS} -Q checkout -P $BRANCH $COMMON
${CVS} -Q checkout -P $BRANCH $MODULE
fi
cd $MODULE
}
###################################create branch based on a tag##############################################
branch()
{
if [ $# -lt 1 ];then
echo "#####################################branch USAGE##############################"
echo "Usage: branch BRANCH_NAME"
return
fi
BRANCH_NAME=$1
CVSROOT=":ServerType:USERID@servername:port/CVSRepository"
export CVSROOT
cvs rtag Root_${BRANCH_NAME} Project_Name
cvs rtag -b -r Root_${BRANCH_NAME} ${BRANCH_NAME} Project_Name
}