<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Parm Patram &#187; Scripts</title>
	<atom:link href="http://oracle.3dub.com/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://oracle.3dub.com</link>
	<description>Oracle, Linux and UNIX tips, tricks and stuff</description>
	<lastBuildDate>Fri, 03 Feb 2012 18:14:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Script to add FTP users</title>
		<link>http://oracle.3dub.com/2011/01/14/script-to-add-ftp-users/</link>
		<comments>http://oracle.3dub.com/2011/01/14/script-to-add-ftp-users/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 19:07:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=717</guid>
		<description><![CDATA[
#!/bin/sh

echo > done.out
for line in `cat data.txt`; do

        echo
        echo "#++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        user=`echo $line &#124; awk -F':' '{print $1}'`
        dir='/ftp/ccsftp/'`echo $line &#124; awk -F':' '{print $2}'`
   [...]]]></description>
			<content:encoded><![CDATA[<pre>
#!/bin/sh

echo > done.out
for line in `cat data.txt`; do

        echo
        echo "#++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        user=`echo $line | awk -F':' '{print $1}'`
        dir='/ftp/ccsftp/'`echo $line | awk -F':' '{print $2}'`
        passwd=`mkpasswd -l 8 -d 2 -C 2 -s 0`
        echo $user : $dir : $passwd >> done.out
        echo useradd -g ccsftp -d $dir -s /usr/bin/rssh $user
        echo "echo $passwd | passwd --stdin $user"
        echo "pure-pw useradd $user -u 518 -g 519 -d ${dir} -N 4000"
        echo "pure-pw usermod $user -d ${dir}"
        echo "chown 518:519 ${dir}"
        echo pure-pw mkdb
        echo "#++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        echo

done
</pre>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2011/01/14/script-to-add-ftp-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to run packet capture</title>
		<link>http://oracle.3dub.com/2010/12/29/script-to-run-packet-capture/</link>
		<comments>http://oracle.3dub.com/2010/12/29/script-to-run-packet-capture/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 18:36:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=700</guid>
		<description><![CDATA[http://oracle.3dub.com/scripts/tcpdump.sh.txt
]]></description>
			<content:encoded><![CDATA[<p>http://oracle.3dub.com/scripts/tcpdump.sh.txt</p>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/12/29/script-to-run-packet-capture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BASH function that passes variables by reference</title>
		<link>http://oracle.3dub.com/2010/12/14/bash-function-that-passes-variables-by-reference/</link>
		<comments>http://oracle.3dub.com/2010/12/14/bash-function-that-passes-variables-by-reference/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 02:10:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=694</guid>
		<description><![CDATA[http://oracle.3dub.com/flex_function.sh.txt
]]></description>
			<content:encoded><![CDATA[<p>http://oracle.3dub.com/flex_function.sh.txt</p>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/12/14/bash-function-that-passes-variables-by-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BB page to show/fra usage</title>
		<link>http://oracle.3dub.com/2010/12/11/bb-page-to-showfra-usage/</link>
		<comments>http://oracle.3dub.com/2010/12/11/bb-page-to-showfra-usage/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 20:49:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Big Brother]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=691</guid>
		<description><![CDATA[
#!/bin/bash
# parmanand.patram; 2010-12-11
# create a single page to show all db /fra usage across the environment

# SETUP
LOGSDIR=/bb/bbvar/logs
OUTFILE=/usr/local/bb/www/allfra/allfra.html
TMPFILE=/usr/local/bb/www/allfra/fralines.tmp
WORKDIR=/usr/local/bb/www/allfra

cd $LOGSDIR

#cleanup
rm -f ${OUTFILE}*

for file in `find . -name "*.disk" &#124; sort`; do
        grep -i fra $file > $TMPFILE
        if [ -s "$TMPFILE" ]; then
 [...]]]></description>
			<content:encoded><![CDATA[<pre>
#!/bin/bash
# parmanand.patram; 2010-12-11
# create a single page to show all db /fra usage across the environment

# SETUP
LOGSDIR=/bb/bbvar/logs
OUTFILE=/usr/local/bb/www/allfra/allfra.html
TMPFILE=/usr/local/bb/www/allfra/fralines.tmp
WORKDIR=/usr/local/bb/www/allfra

cd $LOGSDIR

#cleanup
rm -f ${OUTFILE}*

for file in `find . -name "*.disk" | sort`; do
        grep -i fra $file > $TMPFILE
        if [ -s "$TMPFILE" ]; then
                SERVER=`echo $file  | sed 's/^..//' | awk -F'.' '{print $1}' | awk -F',' '{print $1}'`

                while read line
                do
                        COLOR="green"
                        #color the red ones
                        if [ ! -z "`echo $line | grep -i '\&#038;red'`" ]; then
                                COLOR="red"
                                echo "
<table border='1'>
<tr bgcolor=\"$COLOR\">
<td> $SERVER </td>
<td>$line</td>

" >> ${OUTFILE}.${SERVER}.red
                                echo '</table>

' >> ${OUTFILE}.${SERVER}.red
                        elif [ ! -z "`echo $line | grep -i '\&#038;yellow'`" ]; then
                                COLOR="yellow"
                                echo "
<table border='1'>
<tr bgcolor=\"$COLOR\">
<td> $SERVER </td>
<td>$line</td>

" >> ${OUTFILE}.${SERVER}.yellow
                                echo '</table>

' >> ${OUTFILE}.${SERVER}.yellow
                        else
                                echo "
<table border='1'>
<tr bgcolor=\"$COLOR\">
<td> $SERVER </td>
<td>$line</td>

" >> ${OUTFILE}.${SERVER}.green
                                echo '</table>

' >> ${OUTFILE}.${SERVER}.green
                        fi
                done < $TMPFILE
        fi
done

echo "
<table>" > $OUTFILE
# show red
cd $WORKDIR
for i in `ls *.red`
do
        cat $i >> $OUTFILE
done

# show yellow
cd $WORKDIR
for i in `ls *.yellow`
do
        cat $i >> $OUTFILE
done

#show green
for i in `ls *.green`
do
        cat $i >> $OUTFILE
done
echo "</table>

" >> $OUTFILE
</pre>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/12/11/bb-page-to-showfra-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BB test to identify Oracle DBS on the system</title>
		<link>http://oracle.3dub.com/2010/12/11/bb-test-to-identify-oracle-dbs-on-the-system/</link>
		<comments>http://oracle.3dub.com/2010/12/11/bb-test-to-identify-oracle-dbs-on-the-system/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 18:29:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Big Brother]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=688</guid>
		<description><![CDATA[
#!/bin/sh

#
# $Revision: 1
# $Date: 11/09/2010
# $Author: Parm Patram
# $Description: This scripts outputs the list of oracle databases to BBDISPLAY
# $Instructions: Modify the variables BBHOME, LOG_HIST_COUNT and WARNCOLOR
#                to match your system and monitoring requirements.
#
# Shamelessly stolen from the bb-who.sh script

# [...]]]></description>
			<content:encoded><![CDATA[<pre>
#!/bin/sh

#
# $Revision: 1
# $Date: 11/09/2010
# $Author: Parm Patram
# $Description: This scripts outputs the list of oracle databases to BBDISPLAY
# $Instructions: Modify the variables BBHOME, LOG_HIST_COUNT and WARNCOLOR
#                to match your system and monitoring requirements.
#
# Shamelessly stolen from the bb-who.sh script

# Add to the clients in $BBHOME/etc/bb-bbexttab like so:
# localhost: : bb-which_dbs.sh

#
# Uncomment the line below to run manually
#

#DEBUG="Y"

#
# INITIALIZE VARIABLES WE'LL BE NEEDING
#
TEST="DBS"                              # THE NAME OF OUR TEST
CHANGE_COLOR="red"                       # Color to turn when new DB is found

# When we find a new DB on the system, how long aferwards
# should we continue to holler?
DELAY_COUNT=5

if test "$DEBUG" = "Y"
then
        echo "*** DEBUG NOT IMPLEMENTED! ***"
fi

#################################################################
#
#   NO CONFIGURATION BEYOND THIS POINT
#
#################################################################

#
# Check that we have a basic environment setup
#
if test "$BBHOME" = ""
then
        echo ERROR: BBHOME variable not set
        exit 1
fi

if test ! "$BBTMP"                      # GET DEFINITIONS IF NEEDED
then
        # echo "*** LOADING BBDEF ***"
        . $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

#
# Initialization line
#

MACHINE=`hostname | $SED 's/\./,/g'`
COLOR="green"
DATE=`date`

SENDFILE=$BBTMP/$TEST
TESTFILE=$BBTMP/${TEST}.test
COUNTFILE=$BBTMP/${TEST}.count
COUNT=`/bin/cat $COUNTFILE`
NEWDBS=$BBTMP/${TEST}.new
MISSDBS=$BBTMP/${TEST}.missing
/bin/ps -ef | /bin/grep ora_smon| /bin/grep -v grep | /bin/awk -F'_' '{print $3}'|sort| sed 's/^/DB:/' > $TESTFILE

# make sure we have a SENDFILE, newfile and missing file
touch $SENDFILE $NEWDBS $MISSDBS
# send stderr to DBCHANGES to cater for any errors or
# for when the thing first starts up.
DBCHANGES=`/usr/bin/diff $SENDFILE $TESTFILE 2>&#038;1`

# See if there are any changes in the list of DBs
if [ ! -z "$DBCHANGES" ]; then
        echo "Changes!"
        echo $DBCHANGES
        # increment the counts
        echo "Current count: $COUNT"
        let COUNT=$COUNT+1
        echo $COUNT > $COUNTFILE
        echo "New count: `/bin/cat $COUNTFILE`"

        # Let's see if it is time to stop hollering!
        if [ "$COUNT" -gt "$DELAY_COUNT" ]; then
                echo "COUNT $COUNT exceeds treshold $DELAY_COUNT"
                # update our sendfile
                /bin/cp -f $TESTFILE $SENDFILE
                # zero out the count
                echo 0 > $COUNTFILE
                # stop hollering
                COLOR="green"
        else # we are still in alarm mode, identify the new and/or missing DBs
                # generate new db list
                echo "NEW DATABASES ON SYSTEM:" > $NEWDBS
                /usr/bin/diff $SENDFILE $TESTFILE | /bin/grep ^\> | awk -F':' '{print $2}' >> $NEWDBS
                echo "++++++++++++++++++++++++++++++" >> $NEWDBS

                # generate missing db list
                echo "DATABASES MISSING FROM SYSTEM:" > $MISSDBS
                /usr/bin/diff $SENDFILE $TESTFILE | /bin/grep ^\< | awk -F':' '{print $2}' >> $MISSDBS
                echo "++++++++++++++++++++++++++++++" >> $MISSDBS

                echo "NEW: "; cat $NEWDBS
                echo "MISSING: "; cat $MISSDBS

                # check to see if the new and missing files are more than 2 lines
                # long (header and footer)
                if [ "`wc -l $MISSDBS | awk '{print $1}'`" -gt "2" ]; then
                        COLOR="yellow"
                else
                        #null the missing file
                        cat /dev/null > $MISSDBS
                fi

                if [ "`wc -l $NEWDBS | awk '{print $1}'`" -gt "2" ]; then
                        COLOR="red"
                else
                        #null the new file
                        cat /dev/null > $NEWDBS
                fi
        fi
fi

CMD_OUT="status $MACHINE.$TEST $COLOR $DATE
CURRENT DBS:
`/bin/cat $TESTFILE`
++++++++++++++++++++++++++++++++
`/bin/cat $NEWDBS`
`/bin/cat $MISSDBS`
"

#
# Send a status update to the Big Brother display unit
#

#
# Debugging
#
if test "$DEBUG" = "Y"
then
        echo "COLOR = ${COLOR}"
        `cat $BBTMP/$TEST`
        echo $CMD_OUT
else
        echo $BB $BBDISP "$CMD_OUT"  # SEND IT TO BBDISPLAY
        echo $BB $BBDISP "$CMD_OUT" >> /tmp/bb-which_dbs.out
fi

# cleanup section
#
/bin/rm -f $NEWDBS $MISSDBS
#
# END OF bb-which_dbs.sh
#
</pre>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/12/11/bb-test-to-identify-oracle-dbs-on-the-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to find and clear FAULTED resources in VCS</title>
		<link>http://oracle.3dub.com/2010/11/25/script-to-find-and-clear-faulted-resources-in-vcs/</link>
		<comments>http://oracle.3dub.com/2010/11/25/script-to-find-and-clear-faulted-resources-in-vcs/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 13:35:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VCS]]></category>
		<category><![CDATA[Vertias]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=680</guid>
		<description><![CDATA[#!/bin/sh
#
# parmanand patram; 2010-11-25
# find and clear faulted VCS resource
#
# This script takes a list of VCS resource groups
# and clears any FAULTED states in the cluster.
# ex.
# clear_VCS_faulted.sh 'GROUP1 GROUP2 ...'

VCS_GROUPS=$1
VCS_BINPATH=/opt/VRTSvcs/bin

for VCS_GROUP in ${VCS_GROUPS}
do
        # hares will show all resources of this group that are faulted
  [...]]]></description>
			<content:encoded><![CDATA[<pre>#!/bin/sh
#
# parmanand patram; 2010-11-25
# find and clear faulted VCS resource
#
# This script takes a list of VCS resource groups
# and clears any FAULTED states in the cluster.
# ex.
# clear_VCS_faulted.sh 'GROUP1 GROUP2 ...'

VCS_GROUPS=$1
VCS_BINPATH=/opt/VRTSvcs/bin

for VCS_GROUP in ${VCS_GROUPS}
do
        # hares will show all resources of this group that are faulted
        # but we will only need to clear based on the unique hostname
        for SYS in `${VCS_BINPATH}/hares -display -group ${VCS_GROUP} -attribute State | grep FAULTED | awk '{print $3}' | sort | uniq`
        do
        #echo ${VCS_BINPATH}/hares -display -group ${VCS_GROUP} -attribute State | grep FAULTED
        ${VCS_BINPATH}/hagrp -clear ${VCS_GROUP} -sys ${SYS}
        done
done</pre>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/11/25/script-to-find-and-clear-faulted-resources-in-vcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run SQL commands from shell script</title>
		<link>http://oracle.3dub.com/2010/11/15/run-sql-commands-from-shell-script/</link>
		<comments>http://oracle.3dub.com/2010/11/15/run-sql-commands-from-shell-script/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 21:32:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL & PL/SQL]]></category>
		<category><![CDATA[SQLPLUS]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=669</guid>
		<description><![CDATA[#!/bin/bash
#
# login to database and run a query
SQL_HOME=WHERE
LOG_HOME=WHERE
SQL_USER=WHAT
SQL_PASS=WHAT
SQL_HOST=WHAT
SQL_DB=WHAT
SQL_PORT=1521
LOGFILE=${SQL_HOME}/output.log
SQL_LOGIN_STR=&#8221;${SQL_HOME}/sqlplus -S ${SQL_USER}/${SQL_PASS}@${SQL_HOST}:${SQL_PORT}/${SQL_DB} &#8221;
cd $SQL_HOME
RESULT=`${SQL_LOGIN_STR} &#60;&#60; EOF
SET HEADING OFF
SELECT NAME FROM V\\$DATABASE;
exit;
EOF`
if [ $RESULT == $SQL_DB ]; then
echo `date`&#8221;: OK: $RESULT&#8221; &#124; sed &#8217;s/\n//g&#8217; &#62;&#62; $LOGFILE
else
echo `date`&#8221;: Got Error: $RESULT&#8221; &#124; sed &#8217;s/\n//g&#8217; &#62;&#62; $LOGFILE
fi
]]></description>
			<content:encoded><![CDATA[<p>#!/bin/bash</p>
<p>#<br />
# login to database and run a query</p>
<p>SQL_HOME=WHERE<br />
LOG_HOME=WHERE<br />
SQL_USER=WHAT<br />
SQL_PASS=WHAT<br />
SQL_HOST=WHAT<br />
SQL_DB=WHAT<br />
SQL_PORT=1521<br />
LOGFILE=${SQL_HOME}/output.log</p>
<p>SQL_LOGIN_STR=&#8221;${SQL_HOME}/sqlplus -S ${SQL_USER}/${SQL_PASS}@${SQL_HOST}:${SQL_PORT}/${SQL_DB} &#8221;</p>
<p>cd $SQL_HOME</p>
<p>RESULT=`${SQL_LOGIN_STR} &lt;&lt; EOF<br />
SET HEADING OFF<br />
SELECT NAME FROM V\\$DATABASE;<br />
exit;<br />
EOF`</p>
<p>if [ $RESULT == $SQL_DB ]; then<br />
echo `date`&#8221;: OK: $RESULT&#8221; | sed &#8217;s/\n//g&#8217; &gt;&gt; $LOGFILE<br />
else<br />
echo `date`&#8221;: Got Error: $RESULT&#8221; | sed &#8217;s/\n//g&#8217; &gt;&gt; $LOGFILE<br />
fi</p>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2010/11/15/run-sql-commands-from-shell-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show table creation properties using dbms_metadata.get_ddl</title>
		<link>http://oracle.3dub.com/2008/09/11/show-table-creation-properties-using-dbms_metadataget_ddl/</link>
		<comments>http://oracle.3dub.com/2008/09/11/show-table-creation-properties-using-dbms_metadataget_ddl/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 13:30:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://oracle.3dub.com/?p=133</guid>
		<description><![CDATA[set pages 0
set long 999999
select dbms_metadata.get_ddl(&#8217;TABLE&#8217;, &#8216;EMP&#8217;, &#8216;SCOTT&#8217;) from dual;
NOTE: all of the parameters must be uppercase or the query will fail.
]]></description>
			<content:encoded><![CDATA[<p>set pages 0<br />
set long 999999<br />
select dbms_metadata.get_ddl(&#8217;TABLE&#8217;, &#8216;EMP&#8217;, &#8216;SCOTT&#8217;) from dual;</p>
<p>NOTE: all of the parameters must be uppercase or the query will fail.</p>
]]></content:encoded>
			<wfw:commentRss>http://oracle.3dub.com/2008/09/11/show-table-creation-properties-using-dbms_metadataget_ddl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

