<?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>Tech Jawa &#187; Code</title>
	<atom:link href="http://www.techjawa.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techjawa.com</link>
	<description>www.techjawa.com</description>
	<lastBuildDate>Wed, 10 Mar 2010 19:11:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Shell Script &#8211; Server Maintenance</title>
		<link>http://www.techjawa.com/2009/06/24/shell-script-server-maintenance/</link>
		<comments>http://www.techjawa.com/2009/06/24/shell-script-server-maintenance/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 15:17:38 +0000</pubDate>
		<dc:creator>Corey DeGrandchamp</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.techjawa.com/?p=760</guid>
		<description><![CDATA[So here&#8217;s my first shell script, written for a server at work who has maintenance tasks that need to be completed, and the commands get tedious to input and remember, now all you have to remember is ./maintenance
The script automates 4 tasks that our server has. Restarting out PostgreSQL database, restarting apache, vacuuming the database, [...]]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s my first shell script, written for a server at work who has maintenance tasks that need to be completed, and the commands get tedious to input and remember, now all you have to remember is ./maintenance</p>
<p>The script automates 4 tasks that our server has. Restarting out PostgreSQL database, restarting apache, vacuuming the database, and running our custom import scripts, which has to be done as a specific user each day, and NOT as root&#8230; which has caused issues in the past, but now if you run them with the script I wrote, there&#8217;s no issue at all.</p>
<p>When launched, the script displays a menu for you, on which you make your choices.</p>
<p><a href="http://www.techjawa.com/wp-content/uploads/2009/06/scriptmenu.jpg" rel="shadowbox[post-760];player=img;"><img src="http://www.techjawa.com/wp-content/uploads/2009/06/scriptmenu-300x86.jpg" alt="scriptmenu" title="scriptmenu" width="300" height="86" class="aligncenter size-medium wp-image-762" /></a></p>
<p>You can then make your choice, via number, and it will complete the task and prompt you to continue.<br />
When a wrong choice is made it tells you that you need to select a number from the list. The help command gives you an idea of what each other command does, and exit obviously exits the script.</p>
<p>So here&#8217;s a video to demonstrate how the menu system works.</p>
<p><center><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bQs59NQMQDo&#038;hl=en&#038;fs=1&#038;color1=0xFF6600f&#038;color2=0xFF6600"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bQs59NQMQDo&#038;hl=en&#038;fs=1&#038;color1=0xFF6600&#038;color2=FF6600" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></center></p>
<p>Its a simple shell script, but it works, and it works well for what it does.<br />
And of course I&#8217;d want to share the actual script with you, and document it in my blog,<br />
so here it is, Frank&#8217;s maintenance script!</p>
<pre>
#######################################################
#  _______        _            _                      #
# |__   __|      | |          | |                     #
#    | | ___  ___| |__        | | __ ___      ____ _  #
#    | |/ _ \/ __|  _ \   _   | |/ _` \ \ /\ / / _` | #
#    | |  __/ (__| | | | | |__| | (_| |\ V  V / (_| | #
#    |_|\___|\___|_| |_|  \____/ \__,_| \_/\_/ \__,_| #
#                                                     #
#           www.techjawa.com/category/code            #
#             www.corey.degrandchamp.com              #
#                                                     #
#######################################################
#                                                     #
# Written  By: Corey DeGrandchamp                     #
# Written  On: June 18, 2009                          #
# Written For: Michigan Drill Corporation             #
# Description: This shell script will automate all of #
#              the maintenance tasks on Frank.        #
#                                                     #
#######################################################
#                                                     #
# Edit   Date: June 24, 2009                          #
# Edit     By: Corey DeGrandchamp                     #
# About  Edit: Fixed script so the heading/title will #
#              show every time now, also made it      #
#              pause and wait for the ENTER key to    #
#              be pressed before it continues.        #
#                                                     #
#######################################################

#!/bin/bash

# Display the title.
clear
echo '
     __  __    __    ____  _  _  ____  ____  _  _    __    _  _  ___  ____
    (  \/  )  /__\  (_  _)( \( )(_  _)( ___)( \( )  /__\  ( \( )/ __)( ___)
     )    (  /(__)\  _)(_  )  (   )(   )__)  )  (  /(__)\  )  (( (__  )__)
    (_/\/\_)(__)(__)(____)(_)\_) (__) (____)(_)\_)(__)(__)(_)\_)\___)(____)

	'
# Display possible choices.
CHOICES="RESTART_POSTGRESQL RESTART_APACHE VACUUM_DATABASE RUN_IMPORTS HELP EXIT"
# Define commands for choices.
select choice in $CHOICES; do
	if [ "$choice" = "RESTART_POSTGRESQL" ]; then
		/etc/rc.d/init.d/postgresql restart
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Finished restarting PostgreSQL."
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	elif [ "$choice" = "RESTART_APACHE" ]; then
		service httpsd restart
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Finished restarting Apache."
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	elif [ "$choice" = "VACUUM_DATABASE" ]; then
		su ********-c "/usr/bin/vacuumdb -* *******"
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Finished vacuuming the database."
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	elif [ "$choice" = "RUN_IMPORTS" ]; then
		su ********-c "/home/********/********/********/IMPORT"
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Finished running the imports."
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	elif [ "$choice" = "HELP" ]; then
		clear
		echo "RESTART_POSTGRES"
		echo "     - Useful for when SOEFIE giving errors, or functioning slowly."
		echo ""
		echo "RESTART_APACHE"
		echo "     - When changes are made to websites, or websites are not working."
		echo ""
		echo "VACUUM_DATABASE"
		echo "     - This will vacuum the veritime database, clearing our all of the junk."
		echo ""
		echo "RUN_IMPORTS"
		echo "     - Runs the imports from the AS/400 to SOEFIEs database."
		echo ""
		echo "HELP"
		echo "     - Displays this menu"
		echo ""
		echo "EXIT"
		echo "     - Exits the program."
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	elif [ "$choice" = "EXIT" ]; then
		clear
		exit
	else
		echo ""
		echo ""
		echo ""
		echo ""
		echo "Please choose a number from the list."
		echo ""
		echo "Press ENTER to continue."
		read
		clear
	fi
# Display the title after each choice again.
	echo '
     __  __    __    ____  _  _  ____  ____  _  _    __    _  _  ___  ____
    (  \/  )  /__\  (_  _)( \( )(_  _)( ___)( \( )  /__\  ( \( )/ __)( ___)
     )    (  /(__)\  _)(_  )  (   )(   )__)  )  (  /(__)\  )  (( (__  )__)
    (_/\/\_)(__)(__)(____)(_)\_) (__) (____)(_)\_)(__)(__)(_)\_)\___)(____)

	'
done
</pre>
<p>Some parts taken out to protect our security&#8230;.</p>
<p>I know there are other ways to do what I achived here, but as I said before, this is my VERY FIRST shell script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techjawa.com/2009/06/24/shell-script-server-maintenance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excel VBScript &#8211; Delete Row if Column &#8220;X&#8221; = &#8220;Value&#8221;</title>
		<link>http://www.techjawa.com/2009/06/18/excel-vbscript-delete-row-if-column-x-value/</link>
		<comments>http://www.techjawa.com/2009/06/18/excel-vbscript-delete-row-if-column-x-value/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 17:18:54 +0000</pubDate>
		<dc:creator>Corey DeGrandchamp</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.techjawa.com/?p=726</guid>
		<description><![CDATA[This is the first entry in my new &#8220;Code&#8221; category, as I do a LOT of coding for work lately.
So the following script is one of my firsts that I wrote for work.

Sub Delete_Unchanged_Prices()

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  _______        _            [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first entry in my new &#8220;Code&#8221; category, as I do a LOT of coding for work lately.</p>
<p>So the following script is one of my firsts that I wrote for work.</p>
<pre>
Sub Delete_Unchanged_Prices()

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  _______        _            _                      '
' |__   __|      | |          | |                     '
'    | | ___  ___| |__        | | __ ___      ____ _  '
'    | |/ _ \/ __|  _ \   _   | |/ _` \ \ /\ / / _` | '
'    | |  __/ (__| | | | | |__| | (_| |\ V  V / (_| | '
'    |_|\___|\___|_| |_|  \____/ \__,_| \_/\_/ \__,_| '
'                                                     '
'           www.techjawa.com/category/code            '
'             www.corey.degrandchamp.com              '
'                                                     '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                                                     '
' Written  By: Corey DeGrandchamp                     '
' Written  On: December 10, 2008                      '
' Written For: Michigan Drill Corporation             '
' Description: This Excel VBScript will search column '
'              B, and if a cell in B has a null value '
'              then the script deltes the entire row. '
'              This is mainly used for our end of the '
'              year cost changes, but can be modified '
'              to suit your own needs.                '
'                                                     '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                                                     '
' Edit   Date: June 18, 2009                          '
' About  Edit: Added information.                     '
'                                                     '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
  Dim Rng As Range, ix As Long
  Set Rng = Intersect(Range("B:B"), ActiveSheet.UsedRange)
  For ix = Rng.Count To 1 Step -1
      If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = "" Then
        Rng.Item(ix).EntireRow.Delete
      End If
  Next
done:
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
End Sub
</pre>
<p>It basically goes through and checks every row in column B, and if there is a cell with a value of &#8220;&#8221; (AKA null) then it removes the entire row.</p>
<p>This can be changed to any column/value combination, but this is the specific combination we need at work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techjawa.com/2009/06/18/excel-vbscript-delete-row-if-column-x-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
