<?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>GeekyBoy.com</title>
	<atom:link href="http://www.geekyboy.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.geekyboy.com</link>
	<description>Information Technology I may want to remember someday.</description>
	<lastBuildDate>Wed, 16 May 2012 17:04:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Add items to Ubuntu 12.04 Unity Launcher (quicklaunch)</title>
		<link>http://www.geekyboy.com/archives/384</link>
		<comments>http://www.geekyboy.com/archives/384#comments</comments>
		<pubDate>Sun, 06 May 2012 02:08:22 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[phpstorm]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[unity launcher]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=384</guid>
		<description><![CDATA[Creating a Unity Launcher item in Ubuntu 12.04 Precise Pangolin is a bit challenging. Here is how I took care of it for Zend Studio and PHPStorm.]]></description>
			<content:encoded><![CDATA[<p>The recent upgrade to Ubuntu 12.04 Precise Pangolin left me somewhat hanging when it comes to creating launchers on the desktop, and also in the Unity Launcher (also called quicklaunch in some places) for Zend Studio and PHPStorm. In Gnome prior to Unity in Ubuntu it was easy to right click the desktop and select Create Launcher to create icons on the desktop to launch applications or scripts, but in 12.04 that options is gone. So here is how I solved some of the issues.</p>
<h3>Method 1</h3>
<p>For Netbeans and Eclipse based editors like Zend Studio or Aptana it is not too bad. I created a *.desktop files for each one and put it in the /usr/share/applications/ folder. I believe you can also create a folder in /home/username/.local/applications/ and put it there instead, but I have not tested it. Here is how I created a zendstudio.desktop file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Desktop Entry<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">Version</span>=<span style="color: #000000;">1.0</span>
<span style="color: #007800;">Name</span>=Zend Studio
<span style="color: #007800;">GenericName</span>=Zend Studio
X-GNOME-FullName=Zend Studio PHP IDE
<span style="color: #007800;">Comment</span>=PHP IDE <span style="color: #000000; font-weight: bold;">for</span> PHP development
<span style="color: #007800;">Type</span>=Application
<span style="color: #007800;">Categories</span>=Application;Development;PHP;IDE;Programming
<span style="color: #007800;">Exec</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>username<span style="color: #000000; font-weight: bold;">/</span>Zend<span style="color: #000000; font-weight: bold;">/</span>ZendStudio-9.0.2<span style="color: #000000; font-weight: bold;">/</span>ZendStudio
<span style="color: #007800;">TryExec</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>username<span style="color: #000000; font-weight: bold;">/</span>Zend<span style="color: #000000; font-weight: bold;">/</span>ZendStudio-9.0.2<span style="color: #000000; font-weight: bold;">/</span>ZendStudio
<span style="color: #007800;">Terminal</span>=<span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #007800;">StartupNotify</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #007800;">Icon</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>username<span style="color: #000000; font-weight: bold;">/</span>Zend<span style="color: #000000; font-weight: bold;">/</span>ZendStudio-9.0.2<span style="color: #000000; font-weight: bold;">/</span>icon.xpm</pre></div></div>

<p>After creating the file above I then launched Zend Studio by going to the Zend folder in my home directory and double clicking the ZendStudio executable. Once the application is running I right clicked the icon in the Unity Launcher and select &#8220;Lock to Launcher&#8221;. Now the application stays in the Unity Launcher.</p>
<p>The above worked for most applications, but did NOT work for <a href="http://www.jetbrains.com/phpstorm/index.html">PHPStorm</a> which launches by using a shell script named PhpStorm.sh. I tried doing the method above, and I also tried creating the desktop file and then dragging and dropping it to the Launcher, and that did not work either.</p>
<h3>Method 2</h3>
<p>Another method I found was to install the &#8216;gnome-panel&#8217; package. (Actually it was already installed on my system for some reason.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--no-install-recommends</span> gnome-panel</pre></div></div>

<p>With the gnome-panel I was now able to create a launcher on the desktop using the command below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gnome-desktop-item-edit ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--create-new</span></pre></div></div>

<p>In the create launcher dialog I filled it out as follows:<br />
Type: Application<br />
Name: PhpStorm<br />
Command: /bin/bash /home/username/PhpStorm/PhpStorm-117.257/bin/phpstorm.sh</p>
<p>NOTE: You could use /bin/sh or whatever shell you use. I use bash so that is why I put /bin/bash.</p>
<p>To create a shortcut in the Unity Launcher I double clicked the new desktop launcher I created above. (NOTE: If you start PHPStorm by executing the phpstorm.sh you do not get any options at all when right clicking the icon in the Unity Launcher.) Then when PHPStorm was running I was then able to right click on the icon in the Unity Launcher and selected &#8220;Lock to Launcher&#8221;. Voila! Now I have phpstorm on the Unity Launcher.</p>
<h3>Method 3</h3>
<p>This option is built right into PHPStorm v4.0.1 (I am not sure about other versions). The wonderful people at JetBrains created a handy item in Tools to automatically create a menu item for you. Simply click on Tools->Create Desktop entry&#8230; and the IDE will create an icon in the Dash menu, but not in the Unity Launcher. However, by starting the JetBrains PhpStorm IDE from the Unity Dash you can then right click on the icon that shows up in the Unity Launcher and select &#8220;Lock to Launcher&#8221;. The icon now stays there, even after a reboot/logout.</p>
<p>Update:</p>
<h3>Method 4</h3>
<p>See comment to this post by Shinybird. (Not sure if it works, but it sounds good.)</p>
<p>Enjoy!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/384/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Collect hardware info in Ubuntu</title>
		<link>http://www.geekyboy.com/archives/381</link>
		<comments>http://www.geekyboy.com/archives/381#comments</comments>
		<pubDate>Fri, 27 Apr 2012 14:40:55 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=381</guid>
		<description><![CDATA[Handy terminal commands to collect hardware information in Ubuntu.]]></description>
			<content:encoded><![CDATA[<p>I had some trouble installing/upgrading my system to Ubuntu Precise 12.04, so I reported the bug and wanted to also provide my hardware info with the bug report. I found 2 commands that returned slightly different results about my hardware, but both had usable info.</p>
<p>The best seemed to be:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> lshw</pre></div></div>

<p>Another I came across was:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dmidecode</pre></div></div>

<p>I hope this helps others.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/381/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Executing CakePHP script using Windows Scheduled Task</title>
		<link>http://www.geekyboy.com/archives/376</link>
		<comments>http://www.geekyboy.com/archives/376#comments</comments>
		<pubDate>Fri, 16 Sep 2011 15:21:30 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Cron]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Scheduled Tasks]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=376</guid>
		<description><![CDATA[In Windows adding a scheduled task is just not as straight forward as adding a CRON job using Linux. (Don&#8217;t get me started on troubleshooting a Windows Schedule Task that did not run for some reason.) However, it is not so difficult once you get it figured out. Here is what I did: In this [...]]]></description>
			<content:encoded><![CDATA[<p>In Windows adding a scheduled task is just not as straight forward as adding a CRON job using Linux. (Don&#8217;t get me started on troubleshooting a Windows Schedule Task that did not run for some reason.) However, it is not so difficult once you get it figured out.  Here is what I did:</p>
<p>In this case I wanted to run a CakePHP script as a CRON job, or more accurately, as a Windows Scheduled Task since this customer insisted I create the application and use a Windows server. (I used XAMPP, so it wasn&#8217;t too bad.)</p>
<p>In order to run the script and take full advantage of the models in CakePHP it required that I use the CakePHP shell. Luckily the CakePHP developers created a &#8216;cake.bat&#8217; script that enables this to happen on a Windows machine.  Normally on a Windows or Linux server you can navigate, via command line, to the &#8216;app&#8217; folder and execute the &#8216;cake  name_of_script&#8217; command, but using Windows Scheduled Tasks you need to execute the bat file.</p>
<p>Windows Scheduled Task Settings:<br />
Run: C:\path\to\cake.bat  script_name {without the extension .php}<br />
Start in: C:\path\to\app\folder<br />
Run As: type in the appropriate users</p>
<p>Then of course you will need to go to the Schedule tab and set in the schedule you desire for your script.</p>
<p>Here is a screenshot: (you can see the default folders for xampp were used)</p>
<p><a href="http://www.geekyboy.com/wp-content/uploads/2011/09/windows_schedule_task.gif"><img class="alignnone size-full wp-image-378" title="windows_schedule_task" src="http://www.geekyboy.com/wp-content/uploads/2011/09/windows_schedule_task.gif" alt="" width="408" height="446" /></a></p>
<p>IMPORTANT: This entire process assumes that you have already created your script and placed it in the appropriate directory &#8220;/app/vendors/shells/{name_of_script.php}&#8221;.  It also assumes you understand how to create a cronjob for CakePHP to use.  (see below for a sample)</p>
<p>Sample content of &#8216;script_name.php&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ScriptNameShell <span style="color: #000000; font-weight: bold;">extends</span> Shell <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$uses</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'model1'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'model2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * the main function is kicked off like a contructor
	 *
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Doing something.'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$callingSomething</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">otherFunction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$callingSomething</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> otherFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'This is content from otherFunction.'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/376/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Duplicates using SQL</title>
		<link>http://www.geekyboy.com/archives/369</link>
		<comments>http://www.geekyboy.com/archives/369#comments</comments>
		<pubDate>Fri, 16 Sep 2011 14:30:35 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=369</guid>
		<description><![CDATA[While migrating old data to a new database schema I was unable to activate a PRIMARY KEY on the legacy_customer_id field because there were duplicates. It turned out that the old application did not clean the data really well, and it allowed duplicates to be created where one of the customer_ids had a space character [...]]]></description>
			<content:encoded><![CDATA[<p>While migrating old data to a new database schema I was unable to activate a PRIMARY KEY on the legacy_customer_id field because there were duplicates. It turned out that the old application did not clean the data really well, and it allowed duplicates to be created where one of the customer_ids had a space character making it unique.</p>
<p>I used the following query to test for others:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span>
    customer_id<span style="color: #66cc66;">,</span>
    <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span>customer_id<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">FROM</span>
    customers
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>
    customer_id
<span style="color: #993333; font-weight: bold;">HAVING</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span>customer_id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>This allowed me to find all customer_ids that had duplicates and clean things up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/369/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtualmin error while installing on Ubuntu 10.4</title>
		<link>http://www.geekyboy.com/archives/364</link>
		<comments>http://www.geekyboy.com/archives/364#comments</comments>
		<pubDate>Thu, 01 Sep 2011 20:23:03 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[virtualmin]]></category>
		<category><![CDATA[webmin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lynx]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=364</guid>
		<description><![CDATA[Virtualmin was failing to install on Ubuntu, after I fixed the hostname on the server and updated my hosts file all was good.]]></description>
			<content:encoded><![CDATA[<p>While I am very comfortable using Linux via a command line shell, I think all of us can admit that occasionally we need to look up a command or two due to non-regular use.  Because time is short, and can be expensive when we have tons to do, I usually install Virtualmin (which also installs Webmin) on most of my servers.  It is simply easier to login and get things done quickly.</p>
<p>Well, as I was setting up a new server at my hosting provider today and installing Virtualmin I ran into a little problem.  The server was a fresh install, and Virtualmin would not install on my fresh load of Ubuntu 10.4 (which is a supported OS by Virtualmin).  Instead I received the error:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">... No apport report written because the error message indicates its a followup error from a previous failure
&nbsp;
pkg: dependency problems prevent configuration of virtualmin-base:
virtualmin-base depends on dovecot-common; however:
Package dovecot-common is not configured yet.
virtualmin-base depends on dovecot-imapd; however:
Package dovecot-imapd is not configured yet.
virtualmin-base depends on dovecot-pop3d; however:
Package dovecot-pop3d is not configured yet.
<span style="color: #c20cb9; font-weight: bold;">dpkg</span>: error processing virtualmin-base <span style="color: #7a0874; font-weight: bold;">&#40;</span>--configure<span style="color: #7a0874; font-weight: bold;">&#41;</span>:
dependency problems - leaving unconfigured
Errors were encountered <span style="color: #000000; font-weight: bold;">while</span> processing:
dovecot-common
dovecot-imapd
dovecot-pop3d
virtualmin-base
&nbsp;
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">13</span> - Fatal Error Occurred: Something went wrong during installation: <span style="color: #000000;">0</span>
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">13</span> - Cannot <span style="color: #7a0874; font-weight: bold;">continue</span> installation.
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">14</span> - Attempting to remove virtualmin repository configuration, so the installation can be
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">14</span> - re-attempted after any problems have been resolved.
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">14</span> - Removing temporary directory and files.
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">14</span> - If you are unsure of what went wrong, you may wish to review the log
FATAL - <span style="color: #000000;">2011</span>-09-01 00:07:<span style="color: #000000;">14</span> - <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>virtualmin-install.log</pre></div></div>

<p>Well, after some Google searching I determined that the problem may be related to a bad hostname set on the server.  This was a little confusing because the install also detected this at the beginning and asked me what I would like the hostname set to.  However, it appears that providing the hostname did not make a difference because Virtualmin was not able to set it.</p>
<p>I first tested the hostname to see if this was the problem by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">hostname</span> <span style="color: #660033;">-f</span></pre></div></div>

<p>Sure enough, it warned that the hostname was a problem.  So here is how I fixed things:</p>
<p>First, I had to set the hostname on the server (I use sudo, but you could be logged in as root or change to superuser with su.):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># sudo vi /etc/hostname</span></pre></div></div>

<p>In vi you would edit the hostname to be a fully qualified domain name (FDQN) and saving. (click &#8220;i&#8221; to enter insert mode, then &#8220;esc&#8221; to stop, and hit &#8220;ZZ&#8221; to save and close. Note: these are capital &#8220;ZZ&#8221;.)</p>
<p>Second, this requires a restart of the hostname service to apply the change. (Note: you can use &#8216;restart&#8217; instead of stop and start.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># sudo /etc/init.d/hostname stop</span>
<span style="color: #666666; font-style: italic;"># sudo /etc/init.d/hostname start</span></pre></div></div>

<p>Third, I had to then update my hosts file to also reflect the change. (click &#8220;i&#8221; to enter insert mode, then &#8220;esc&#8221; to stop, and hit &#8220;ZZ&#8221; to save and close. Note: these are capital &#8220;ZZ&#8221;.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># sudo vi /etc/hosts</span></pre></div></div>

<p>IMPORTANT: If you do not include the &#8220;shortname&#8221; after the hostname applications will still not consider this a FDQN.</p>
<p>Example of what should be in the hosts file when you are done:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">127.0.0.1     myhome.domain.com myhome</pre></div></div>

<p>After doing these three steps I was able to successfully install Virtualmin with no issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/364/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tether Android to Ubuntu for free Internet</title>
		<link>http://www.geekyboy.com/archives/362</link>
		<comments>http://www.geekyboy.com/archives/362#comments</comments>
		<pubDate>Thu, 25 Aug 2011 20:32:21 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[htc evo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[android internet sharing]]></category>
		<category><![CDATA[easytether]]></category>
		<category><![CDATA[USB tether]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=362</guid>
		<description><![CDATA[My experience of not having an Internet connection prompted me to prepare in case it happens again.  I found EasyTether, and here is how it works.]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I was without Internet (thanks to AT&amp;T), and was forced to go to Starbucks to check email and commit work I had done.  While I like going to Starbucks, it was not the best working situation for someone who works from home.</p>
<p>Since I have an Android (HTC Evo) I thought about USB tethering the device to my laptop and Internet sharing, but Sprint hits you with a $29.95/month fee to use that option.  Since I am completely able to work locally without a connection to the Internet, I decided to tough it out and wait until AT&amp;T figured out their mess and got me turned back on.</p>
<p>Fast forward a couple of weeks later&#8230; (yes, I am back on the net)</p>
<p>I found some neat applications for my phone that enable someone to bypass the tethering options that Sprint charges for.  One popular application is PdaNet, but it is limited to Windows and Mac. (For those who are still limited by those two platforms, give PdaNet a try.)  Another application I stumbled across called <a title="Easy Tether" href="http://www.mobile-stream.com/easytether/android.html" target="_blank">EasyTether</a> has Linux support, so I gave it a try. (I am actually writting this blog post while using it)</p>
<p>The application for the Droid was available on the Droid Market Place, and their website has the Ubuntu file available for the PC connection. <a title="EasyTether Download page" href="http://mobile-stream.com/easytether/drivers.html" target="_blank">http://mobile-stream.com/easytether/drivers.html</a></p>
<p>I installed the &#8220;Lite&#8221; version from the Droid Market Place (FREE!!! but limits you to non-SSL pages, unless you pay the $9.99 for the full version) The application walks you through the couple of simple steps needed to use it, and even gives you the address above to get your Windows/Mac/Ubuntu/Fedora up and running.</p>
<p>Once I installed the DEB file on my laptop, after downloading it, all I had to do was connect my phone to USB and open the connection via command line.</p>
<p>The command to link up is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">easytether connect</pre></div></div>

<p>Now the next time I am without Internet I am ready. <img src='http://www.geekyboy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/362/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Empty file contents at command line on Linux system</title>
		<link>http://www.geekyboy.com/archives/357</link>
		<comments>http://www.geekyboy.com/archives/357#comments</comments>
		<pubDate>Sat, 13 Aug 2011 13:43:10 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[log file]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=357</guid>
		<description><![CDATA[I wanted to clear the content of a growing error log file, so found a command that did while leaving permissions in place.]]></description>
			<content:encoded><![CDATA[<p>As is often the case I needed to accomplish something, so I tinkered until I figure it out.  I had a web site that I recently moved from a PHP 5.2 to 5.3 enabled server.  It became a problem when I realized my error logs had filled up with 600 MB of deprecated function messages, and after fixing the issues I wanted to clear out the logs.</p>
<p>While there are a few methods of doing this, I wanted to keep it simple.  Here is the command I used:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&gt; filename.log</pre></div></div>

<p>The greater than symbol is the command which pipes nothing to the file, thus clearing it. This cleared up the file quickly, and left the permissions and filename in place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/357/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP and Dreamweaver opening ctp files</title>
		<link>http://www.geekyboy.com/archives/347</link>
		<comments>http://www.geekyboy.com/archives/347#comments</comments>
		<pubDate>Thu, 14 Jul 2011 18:51:12 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[ctp]]></category>
		<category><![CDATA[dreamweaver]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=347</guid>
		<description><![CDATA[How to open CakePHP ctp files using Dreamweaver.]]></description>
			<content:encoded><![CDATA[<p>I have been working with some web designers recently who do not have a lot of PHP coding experience, but fully understand HTML and CSS in code view using Dreamweaver. So, to help them transition projects to using PHP, or more to the point using the CakePHP framework, I have been making preparations to move in that direction.</p>
<p>The hurdle, after setting up the base site using the framework, was to get .ctp files rendering in Dreamweaver. (Their editor of choice.)  Initially Dreamweaver does not understand what the ctp file extension is, and how should it syntax highlight the code.  So we help Dreamweaver out by editing a few of its configuration files. (Note: I only have Dreamweaver CS3, otherwise known as version 9, so I am not sure how it affects later versions of Dreamweaver.  Hopefully future versions of Dreamweaver may already understand the ctp file extension.)</p>
<p><strong>First</strong>, we edit a Dreamweaver base configuration file located at &#8220;C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\Extensions.txt&#8221; and alter 2 lines by adding the CTP file extension as follows:</p>
<pre>
...,INC,JAVA,EDML,MASTER,CTP:All Documents
</pre>
<p>The very first line should look as above at the end.<br />
</p>
<pre>
PHP,PHP3,PHP4,PHP5,TPL,CTP:PHP Files
</pre>
<p>The PHP Files line, which was line 16 for me, should look as above.<br />
</p>
<p><strong>Second</strong>, we <strong>do the exact same thing</strong> to the user configuration file located at &#8220;C:\Documents and Settings\{user}\Application Data\Adobe\Dreamweaver 9\Configuration\Extensions.txt&#8221;. I am not sure why we need to edit the same file in both locations, but that is what is required. (One would think that editing the user configuration file would be enough since it should cascade over the base configuration, but it does not work that way.)</p>
<p><strong>For Windows 7</strong>, there is an additional file that needs to be updated the same way at &#8220;C:\Users\<username>\AppData\Roaming\Adobe\Dreamweaver 9\Configuration\Extensions.txt&#8221;. (Note: For later versions of Dreamweaver there is another folder level under Configuration called &#8220;en_US&#8221; that contains the Extensions.txt file.)</p>
<p><strong>Fourth</strong>, we now need to push Dreamweaver to what type of file ctp is, and how should it be rendered. We do this by editing another configuration file located at &#8220;C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\DocumentTypes\MMDocumentTypes.xml&#8221;.  What we are looking for is around the 75th line where it reads &#8220;servermodel=PHP MySQL&#8221;.</p>
<pre>
winfileextension="php,php3,php4,php5,ctp"
macfileextension="php,php3,php4,php5.ctp"
</pre>
<p>Add the ctp extension to the comma separated list as shown above.<br />
</p>
<p><strong>Your done!</strong> But first you must check one more thing.  After you start Dreamweaver, open the &#8220;Edit->Preferences&#8221; and look at the &#8220;File Types/Editors&#8221;.  Make sure that &#8220;.ctp&#8221; is not in the list to &#8220;Open in code view&#8221;, otherwise Dreamweaver will not allow you to use Design View with ctp files. (Note: Design View is not truly useful since Dreamweaver will still not use the Layout file.  But you can still assign &#8220;Design Time&#8221; styles to render views.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/347/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CakePHP says An Internal Error Has Occurred.</title>
		<link>http://www.geekyboy.com/archives/341</link>
		<comments>http://www.geekyboy.com/archives/341#comments</comments>
		<pubDate>Fri, 18 Mar 2011 18:32:44 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=341</guid>
		<description><![CDATA[Recently I had the wonderful experience of CakePHP informing me that &#8220;An Internal Error Has Occurred&#8221;, with no more indication of what the problem could be. After digging around the CakePHP code I quickly found out that this code is pretty much used for any 500 browser error.  So I started the process of elimination: [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had the wonderful experience of CakePHP informing me that &#8220;An Internal Error Has Occurred&#8221;, with no more indication of what the problem could be.  After digging around the CakePHP code I quickly found out that this code is pretty much used for any 500 browser error.  So I started the process of elimination:</p>
<ol>
<li>The site was working correctly.  I know this because most pages on the site came up just fine.  The error was only on certain pages.</li>
<li>It was not caused by the page not existing on the server.  The controller, action, and models were all named correctly.  I know this because the page was working correct a week ago, and because I did a sanity check to ensure nothing had changed in this area.</li>
<li>I checked to ensure the .htaccess had not been deleted, changed, or renamed.  All was OK here.</li>
<li>I checked the CakePHP logs.  These exist in the &#8216;app/tmp/logs/&#8217; directory.  There were NO errors reported, and no debug entries as well.</li>
<li>I checked the /var/log/messges&#8217; and found no errors reported there.</li>
<li>I checked the /var/apache2/{log_file_name}&#8217; and found no errors there.</li>
</ol>
<p>Everything should have been working, according to the settings and log files, so why was I still receiving this internal error message?</p>
<p>How I solved it:</p>
<p>Finally, I got tired of playing around and simply edited the CakePHP code to output $params array to see the raw reason for the error.  I did this by editing the &#8216;cake/libs/error.php&#8217; file and adding the following around line 176 in the &#8220;error500&#8243; function as the first two lines as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This gave me a simple array that clearly informed me I was missing a table in the DB that was deprecated.  From there I quickly found the entry in the model that was still trying to link to the deprecated table.  I cleaned up the offending model, and now all is well with the world again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/341/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>HTC Evo com.htc.bg problem</title>
		<link>http://www.geekyboy.com/archives/338</link>
		<comments>http://www.geekyboy.com/archives/338#comments</comments>
		<pubDate>Thu, 03 Mar 2011 14:19:20 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[htc evo]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[evo]]></category>
		<category><![CDATA[htc]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=338</guid>
		<description><![CDATA[So about a month ago my HTC Evo started giving me an error message almost every time I looked at the phone. The message was &#8220;The process com.htc.bg has stopped unexpectedly. Please try again.&#8221; or something similar to this. It didn&#8217;t seem to cause any problems, so I simply clicked the &#8220;OK&#8221; button and moved [...]]]></description>
			<content:encoded><![CDATA[<p>So about a month ago my HTC Evo started giving me an error message almost every time I looked at the phone.  The message was &#8220;<strong>The process com.htc.bg has stopped unexpectedly. Please try again.</strong>&#8221; or something similar to this.  It didn&#8217;t seem to cause any problems, so I simply clicked the &#8220;OK&#8221; button and moved on.  However, it was a pain the butt to do this almost every time I tried to do something on the phone.</p>
<p>There was nothing that jumps out at me as a single cause for this new error.  Some on the web stated it was due to the 2.2 upgrade, but I upgraded to 2.2 almost 3 months prior to getting this error so I know that was not it.  I tried un-installing a few apps that I installed around the time it started, but that didn&#8217;t work.</p>
<p>I searched the web and found many solutions ranging from turning off the Facebook auto sync, turning off the weather auto sync, and other such things.  But basically I think it is a shame to turn off features on the phone to fix a problem.  I mean why would I buy a super cool phone, then turn off features that caused me to buy it in the first place to solve a problem?  It just didn&#8217;t make sense to me.</p>
<p>A couple of days ago I finally had enough and decided it was time to back up the contacts and other data to the SD card and reload the phone to the factory settings.  Doing it was easy.  Simply click the Menu button, then select Settings.  Then I selected the SD &#038; phone storage option, and at the bottom is the Factory data reset.  From there you follow the prompts and watch the phone reboot a couple of times.  After about 10 minutes I had a brand new phone again.</p>
<p>Of course it took me a bit longer to reload the apps i wanted, and restoring the contacts.  But it is done.</p>
<p>So, I still am not sure what caused the error, but it is not happening any more.  Problem solved, and I still have all of the nice features I wanted without disabling them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/338/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Centering an HTML table with CSS</title>
		<link>http://www.geekyboy.com/archives/327</link>
		<comments>http://www.geekyboy.com/archives/327#comments</comments>
		<pubDate>Wed, 02 Mar 2011 15:08:13 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=327</guid>
		<description><![CDATA[With the table attribute align="center" it is necessary to define table positions using CSS.  Here is how.]]></description>
			<content:encoded><![CDATA[<p>As you may have noticed, the table align=&#8221;center&#8221; attribute has been deprecated.  So how is one supposed to center a table in an HTML page?  The answer is with CSS.  However, this is not as straight forward as you would think.  Basically we now need to inform the browser to put the same amount of empty space on either side of our tables.  Here is how to do it:</p>
<p><strong>The inline method</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table style=&quot;margin:auto;&quot;&gt;</pre></div></div>

<p>Or if you are using an attached stylesheet you can do it with either classes or the ID method, or by further defining the table tag.</p>
<p><strong>Here are some lines from a CSS stylesheet showing all three methods</strong> (you only need to use one of them, so choose what works best for you)</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* this will define the table tag */</span>
table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* this will define an ID to assign the style to */</span>
# table_align <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* and lastly this is a css class that can be used */</span>
<span style="color: #6666ff;">.table_align</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now, here is the html to make use of these three methods</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table class=&quot;table_align&quot; id=&quot;table_align&quot;&gt;</pre></div></div>

<p><strong>NOTE:</strong> Using &#8220;margin:auto&#8221; is a bit of overkill since it is basically affecting the margin on all 4 sides of the table in some way.  You could center the table more precise by using the margin-left:auto and margin-right:auto and setting two properties in CSS.  However, I usually find that the regular margin:auto generally does the job when the top and bottom are not a concern.</p>
<p>Unfortunately IE (Internet Explorer) once again is different and chooses not to recognize any of the methods above.  So you will be forced to do one of two things.</p>
<ol>
<li>Add the margin:auto style to your &#8220;body&#8221; tag OR
<li>Resort to still using the align=&#8221;center&#8221; attribute for your tables to satisfy IE
</ol>
<p><strong>Examples:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body style=&quot;margin:auto&quot;&gt;
&nbsp;
&lt;table align=&quot;center&quot;&gt;</pre></div></div>

<p>I do not like the previous two examples, but sometimes you gotta do what it takes to reach your entire audience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/327/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting larger terminal size when launching</title>
		<link>http://www.geekyboy.com/archives/321</link>
		<comments>http://www.geekyboy.com/archives/321#comments</comments>
		<pubDate>Tue, 01 Mar 2011 13:13:38 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=321</guid>
		<description><![CDATA[Quick tip on how to launch terminal screens in a larger size, rather than constantly resize them after launching.]]></description>
			<content:encoded><![CDATA[<p>Have you ever noticed that when opening a terminal screen in Linux it is very small?  Who can work like that?  AND in order to do anything I need to drag the corner of the window to make it larger, which is time consuming and drives me crazy because I am opening and closing my terminal screens many times each day.</p>
<p>So, here is a screenshot of how small the terminal screen is when initially launched:</p>
<p><a href="http://www.geekyboy.com/wp-content/uploads/2011/03/small_terminal_window.png"><img class="alignnone size-medium wp-image-322" title="Tiny terminal window on launch" src="http://www.geekyboy.com/wp-content/uploads/2011/03/small_terminal_window-300x187.png" alt="Tiny terminal window on launch" width="300" height="187" /></a></p>
<p>The fix is very simple.  Right click on the launcher for terminal and select &#8220;Properties&#8221;.  When that dialog opens you are going to edit the Command to set the geometry of the window to be BIGGER.  I personally like my terminal to be 175&#215;50, you can vary the size as you wish.</p>
<p>So, here is the new Command: (175 is the width and 50 is the height)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gnome-terminal <span style="color: #660033;">--geometry</span> 175x50</pre></div></div>

<p>Now when my terminal screen opens it is much better:</p>
<p><a href="http://www.geekyboy.com/wp-content/uploads/2011/03/bigger_terminal_size.png"><img class="alignnone size-medium wp-image-323" title="Bigger Terminal Size" src="http://www.geekyboy.com/wp-content/uploads/2011/03/bigger_terminal_size-300x187.png" alt="Bigger Terminal Size" width="300" height="187" /></a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/321/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install APC (alternative PHP cache) on RedHat RHEL 5</title>
		<link>http://www.geekyboy.com/archives/299</link>
		<comments>http://www.geekyboy.com/archives/299#comments</comments>
		<pubDate>Wed, 27 May 2009 20:33:20 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[optcode cache]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[phpize]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[rhel]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=299</guid>
		<description><![CDATA[In this post I show how I installed APC, a Pecl extension to PHP, on a Red Hat 5 server.]]></description>
			<content:encoded><![CDATA[<p>After attending php|tek 2009 I decided it was finally time for me to play with APC, and at least install it on a server to see what all of the excitement is about.  After all, if it is good enough for Facebook it must be pretty beneficial, right?</p>
<p>According to the documentation the following command is what it takes to install:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pecl <span style="color: #c20cb9; font-weight: bold;">install</span> apc</pre></div></div>

<p>However, then I tried this I quickly received an error stating &#8220;phpize: command not found&#8221;.  So after a little searching I discovered that I needed to install php-devel.i386 to enable pear to install packages. (You may also need to install autoconf, automake and libtool to do phpize.  I must have already had them installed.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> php-devel.i386</pre></div></div>

<p>Note: I used sudo, but you can also use su to change to the root user and then run the command as root.</p>
<p>Now after installing that, which also installed a couple of dependencies and updated a couple of other applications, I figured I would be all set.  To the contrary I tried the install apc command again and I received one prompt asking:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Use apxs to <span style="color: #000000; font-weight: bold;">set</span> compile flags <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> using APC with Apache<span style="color: #7a0874; font-weight: bold;">&#41;</span>? <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>:</pre></div></div>

<p>I received a new error after answering &#8220;yes&#8221; :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Sorry, I was not able to successfully run APXS.  Possible reasons:
&nbsp;
<span style="color: #000000;">1</span>.  Perl is not installed;
<span style="color: #000000;">2</span>.  Apache was not compiled with DSO support <span style="color: #7a0874; font-weight: bold;">&#40;</span>--enable-module=so<span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #000000;">3</span>.  <span style="color: #ff0000;">'apxs'</span> is not <span style="color: #000000; font-weight: bold;">in</span> your path.  Try to use <span style="color: #660033;">--with-apxs</span>=<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>apxs
The output of apxs follows
<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>tmpArfGXr<span style="color: #000000; font-weight: bold;">/</span>APC-3.0.10<span style="color: #000000; font-weight: bold;">/</span>configure: line <span style="color: #000000;">3196</span>: apxs: <span style="color: #7a0874; font-weight: bold;">command</span> not found
configure: error: Aborting
ERROR: <span style="color: #000000; font-weight: bold;">`/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>tmpArfGXr<span style="color: #000000; font-weight: bold;">/</span>APC-3.0.10<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-apc-mmap</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #660033;">--with-apxs</span><span style="color: #ff0000;">' failed</span></pre></div></div>

<p>After a few minutes of searching I found a post somewhere that informed me that httpd-devel.i386 also needed to be installed.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> httpd-devel.i386</pre></div></div>

<p>Once the package installed, along with a few more dependencies and updates, I was then ready to try again.  This time all went well, and APC was installed.</p>
<p>One final step was to activate it in the php.ini file.  I added the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">extension</span>=apc.so
apc.enabled = On</pre></div></div>

<p>Next I was ready to restart Apache and see APC in action:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>httpd restart</pre></div></div>

<p>After creating a quick phpinfo() call I could now see that the APC module was indeed active.  Once I copied the apc.php file that comes with the APC install files into a web accessible directory (preferably password protected) I was clearly able to see stats associated with APC.</p>
<p>There is much more you can do with APC settings, etc.  However, that is another story for another time.  Here are a couple of links to help get you started though.<br />
<a href="http://c7y.phparch.com/c/entry/1/art,apc_facebook">C7y Tutorial</a><br />
<a href="http://pecl.php.net/package/APC">Pecl page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/299/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing mhash on RHEL 4 and PHP 4.3.9</title>
		<link>http://www.geekyboy.com/archives/283</link>
		<comments>http://www.geekyboy.com/archives/283#comments</comments>
		<pubDate>Sun, 17 May 2009 15:04:08 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[libmhash]]></category>
		<category><![CDATA[mhash]]></category>
		<category><![CDATA[php4]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[rhel]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=283</guid>
		<description><![CDATA[Recently I had a customer that was receiving errors from an Authorize.Net web submit form in their shopping cart. The error simply stated: &#8220;The gateway no longer supports the requested method of integration.&#8221; While doing some digging I found that they were using a very old web submit method that Authorize.Net no longer supported. There [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a customer that was receiving errors from an Authorize.Net web submit form in their shopping cart.  The error simply stated:</p>
<p><strong><em>&#8220;The gateway no longer supports the requested method of integration.&#8221;</em></strong></p>
<p>While doing some digging I found that they were using a very old web submit method that Authorize.Net no longer supported.  There were two ways to fix the problem:</p>
<ol>
<li>Change to AIM method of submission, which required an SSL certificate that the client did not have.</li>
<li>Change to SIM method of submission, which required either PHP 5.1.2 installed to use the hash_hmac function, or for PHP 4.3.9 it required that mhash be installed on the server.</li>
</ol>
<p>Since the client did not want to spend the extra cash for the SSL certificate, and I could not install PHP 5.1.2 because I had too many other clients on the server that were not ready for the upgrade, I decided to do some searching for a way to install mhash.</p>
<p>It turned out that the Red Hat repositories did not carry php-mhash for RHEL 4, so this meant I needed to look in other areas.  After reading many different blog and BB postings saying that it required an install, then a recompile of PHP I started to get a little worried.  I did not look forward to recompiling PHP.</p>
<p>Finally I found some posts that brought a ray of hope.  There are RPMs available to install php-mhash without the PHP recompile, but it required that libmhash be installed first.  Here are the steps I followed:</p>
<ul>
<li>I went to <a href="http://dag.wieers.com/packages/libmhash/">http://dag.wieers.com/packages/libmhash/</a> and downloaded the newest version of libmhash for my server.</li>
<li>Then I installed using the following to satisfy dependencies of mhash:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-iv</span> libmhash-0.9.1-<span style="color: #000000;">1</span>.rhel3.dag.i386.rpm</pre></div></div>

</li>
<li>Next I downloaded the php-mhash by using:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>rpmfind.net<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>sourceforge<span style="color: #000000; font-weight: bold;">/</span>p<span style="color: #000000; font-weight: bold;">/</span>ph<span style="color: #000000; font-weight: bold;">/</span>phprpms<span style="color: #000000; font-weight: bold;">/</span>php-mhash-4.3.2-<span style="color: #000000;">19</span>.ent.2.i386.rpm</pre></div></div>

</li>
<li>I followed that by installing it using:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-iv</span> php-mhash-4.3.2-<span style="color: #000000;">19</span>.ent.2.i386.rpm</pre></div></div>

</li>
</ul>
<p>After following those steps I created a phpinfo script to see that everything went well:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>I could now plainly see that mhash was installed perfectly, and with further tests I confirmed it was working.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/283/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ubuntu can mount ISO files, and IMG files after converting them to ISO</title>
		<link>http://www.geekyboy.com/archives/274</link>
		<comments>http://www.geekyboy.com/archives/274#comments</comments>
		<pubDate>Fri, 01 May 2009 20:13:15 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[burn to disk]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[mount]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=274</guid>
		<description><![CDATA[Today I needed to create an OEM Microsoft Office 2007 CD and found that I could download the disks directly from the Microsoft site. However, the files that I downloaded were in IMG format. At first I was puzzled, but quickly (via Google) found out that they were essentially ISO files. However, I did not [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to create an OEM Microsoft Office 2007 CD and found that I could download the disks directly from the Microsoft site.  However, the files that I downloaded were in IMG format.  At first I was puzzled, but quickly (via Google) found out that they were essentially ISO files.  However, I did not quickly find anything in Ubuntu that would burn an IMG to disk.<br />
Diligent searching finally revealed that while there were not really ways to burn an IMG to disk, or mount an IMG file directly, there is a tool called ccd2iso that converts the IMG to ISO format.</p>
<p>First I had to install the ccd2iso package via Synaptic package manager, or I could have used &#8216;sudo apt install ccd2iso&#8217;.</p>
<p>After installing this I could simply run the following command from terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ccd2iso myfile.img myfile.iso</pre></div></div>

<p>The same methods can be used for other image type files:<br />
mdf2iso -> myfile.mdf<br />
nrg2iso -> myfile.nrg</p>
<p>Now I have a regular iso file that can be used to serve our purposes by burning to disk or mounting:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop myfile.iso mountname
&nbsp;
or
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop <span style="color: #660033;">-t</span> iso9660 myfile.iso mountname</pre></div></div>

<p>The .nrg files can also be mounted in this manner without converting to ISO by using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop,<span style="color: #007800;">offset</span>=<span style="color: #000000;">307200</span> myfile.nrg mountname</pre></div></div>

<p>NOTE: if this doesn&#8217;t work and you get an error like: &#8220;Unrecognized sector mode (0) at sector 0!&#8221; it may be due to the limitations of the ccd2iso.  In my case the MS Office disk had multiple sessions, and I could not convert it to ISO.</p>
<p>Another post I found on Ubuntuforums said to try the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">growisofs <span style="color: #660033;">-dvd-compat</span> <span style="color: #660033;">-Z</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">dvdrw</span>=dvd.img</pre></div></div>

<p>Where /dev/dvdrw is your dvd/cd burner.</p>
<p>FOLLOWUP:<br />
The IMG file I had from Microsoft was a multi-session disk so I was not able to use the steps above.  However, when I simply changed the file extension to &#8216;.iso&#8217; it worked fine.  There seems to be very little difference between IMG and ISO.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/274/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Finding a text string inside a file on a Linux server</title>
		<link>http://www.geekyboy.com/archives/269</link>
		<comments>http://www.geekyboy.com/archives/269#comments</comments>
		<pubDate>Wed, 29 Apr 2009 18:46:12 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=269</guid>
		<description><![CDATA[It never fails that I find myself hunting for a way to search for a particular text string in files.  Usually I know the file, but often times I also find that I am completely unsure what file contains the string.  Or while I am writting some code I need to find how many files [...]]]></description>
			<content:encoded><![CDATA[<p>It never fails that I find myself hunting for a way to search for a particular text string in files.  Usually I know the file, but often times I also find that I am completely unsure what file contains the string.  Or while I am writting some code I need to find how many files use a certain function.</p>
<p>I know that using grep is the best way to search on a Linux server, so I start there.  Here is the command syntax:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;text string to search for&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>search</pre></div></div>

<p><strong>Examples</strong><br />
To search for a string called &#8220;myFunction&#8221; in all text files located in /var/www/html/*.php use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;myFunction&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/*</span>.php</pre></div></div>

<p>To search recursively in all sub-directories you would alter the command by adding the -r option:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;myFunction&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html</pre></div></div>

<p>Now you have probably noticed that grep prints out the matching lines containing your string, but you may also need the filenames of the files containing the string instead.  You can use the -H option to narrow the output the filename followed by the line containing your search string, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-H</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;myFunction&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html</pre></div></div>

<p>This would output something like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
your_file.php: line containing myFunction
..</pre></div></div>

<p>To print out just the filename you can cut command like this to clean the output further: (Note the one after the f, not an L)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-H</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;myFunction&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -d: <span style="color: #660033;">-f1</span></pre></div></div>

<p>The new cleaner out put would be like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
your_file.php
...</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/269/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Backup files from Linux to a Windows server</title>
		<link>http://www.geekyboy.com/archives/200</link>
		<comments>http://www.geekyboy.com/archives/200#comments</comments>
		<pubDate>Sat, 18 Apr 2009 22:04:47 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Cron]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Remote Backup]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=200</guid>
		<description><![CDATA[Ok, this may be my last disaster recovery and backup blog for a long time. As you can probably tell from the title this blog entry is all about keeping backup strategies as cheap as possible. My strategy is to backup all of my Windows and Linux servers to one central Windows server that is [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, this may be my last disaster recovery and backup blog for a long time.  As you can probably tell from the title this blog entry is all about keeping backup strategies as cheap as possible.</p>
<p>My strategy is to backup all of my Windows and Linux servers to one central Windows server that is running a Tivoli backup agent.  All of my servers are hosted elsewhere, and since it costs $99.00 per server to backup I am getting the most for my money by only backing a single server to tape/SAN.  However that single server carries all of the files that need to be remotely backed up to tape/SAN.</p>
<p>My earlier posts show how to backup the Windows servers:<br />
<a href="http://www.geekyboy.com/archives/160">Windows backup bat script using xcopy</a></p>
<p>Also, how to backup the Windows Domain Controller:<br />
<a href="http://www.geekyboy.com/archives/169">Backup Windows Domain Controller using NTBACKUP via cmd</a></p>
<p>And I also showed how to backup a Linux server to a local file:<br />
<a href="http://www.geekyboy.com/archives/184">Linux backup using CRON to local directory</a></p>
<p>Now I will show how I moved the files backed up on the Linux servers to the Windows server prior to tape/SAN backup.  I have decided to use Samba and mount a directory pointing to a shared folder on the Windows server.  Lets begin:<br />
<span id="more-200"></span></p>
<ol>
<li>Create a share on the Windows server to use as your backup location.</li>
<li>Create a user to use this share, and give the user permissions to use it.</li>
<li>Pick, or create, a user that you&#8217;re going to use to backup the files.  Log in as this user and type &#8216;id&#8217; to get the numeric ID of the user in the Linux OS. (You will need it later.)</li>
<li>Become &#8216;root&#8217;. (This will enable you to perform the next tasks without problems.)</li>
<li>Install samba and samba-client if they are not installed yet.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> samba
yum <span style="color: #c20cb9; font-weight: bold;">install</span> samba-client</pre></div></div>

<p>You will need to answer &#8216;y&#8217; to when prompted.</li>
<li>By default only the root user can mount or unmount a cifs, so we must open it to other users.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">4755</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mount.cifs
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">4755</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>umount.cifs</pre></div></div>

</li>
<li>Now we need to make a directory to use as our mount point.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename</pre></div></div>

</li>
<li>To enable our desired user to mount and unmount this we need to assign ownership to that user. Changing permissions with chmod is not enough.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> userfrom<span style="color: #666666; font-style: italic;">#1 /mnt/sharename</span></pre></div></div>

</li>
<li>Now we need to edit the /etc/fstab file and add an entry.  Replace the user ID of 500 with your user ID from #1.  Replace sharename with your Windows share name.  Replace WINDOWSHOST with your hostname or IP address.  If you don&#8217;t know the shares run smbclient -L WINDOWSHOST

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">//</span>WINDOWSHOST<span style="color: #000000; font-weight: bold;">/</span>sharename <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename cifs <span style="color: #007800;">credentials</span>=<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>smblogin,<span style="color: #007800;">uid</span>=<span style="color: #000000;">500</span>,noauto,user <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></div></div>

</li>
<li>Create/Edit a file /root/smblogin and put the following two lines in it.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">username</span>=WINDOWS USERNAME
<span style="color: #007800;">password</span>=WINDOWS PASSWORD</pre></div></div>

</li>
<li>Now we must give our user from #1 access to the file, but still protect it.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> userfrom<span style="color: #666666; font-style: italic;">#1 /root/smblogin</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>smblogin</pre></div></div>

</li>
<li>If you have IPTABLES active on your server you will need to make sure to add a policy to allow OUTPUT port 445.</li>
<li>Log in as the user from #1</li>
<li>Try to mount the share:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename
<span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename</pre></div></div>

</li>
<li>If that was successful you are now ready to write a script that will automate the moving of your backup files from the Linux to the Windows share. (Script/File = backup.sh)

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>file.tar.gz <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>file.tar.gz
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>sharename</pre></div></div>

<p>Of course you can add this to the end of the file described in <a href="http://www.geekyboy.com/archives/184">Linux backup using CRON to local directory</a> which would create a complete solution for backing up files, then relocating them to a remote Windows server.</li>
<li>Next you will add an entry to the crontab of the user from #1 to happen automagically.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span> <span style="color: #660033;">-u</span> userfrom<span style="color: #666666; font-style: italic;">#1</span></pre></div></div>

</li>
<li>Enter this into the crontab.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Backup at 1:00 A.M. every day. Call 'man 5 crontab' for more information</span>
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>backup.sh</pre></div></div>

</li>
</ol>
<p>Now once this is all done you can rest a little bit easier knowing that your servers are backed up.  I hear the beach calling me now&#8230;.ttyl.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/200/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux backup using CRON to local directory</title>
		<link>http://www.geekyboy.com/archives/184</link>
		<comments>http://www.geekyboy.com/archives/184#comments</comments>
		<pubDate>Fri, 17 Apr 2009 19:15:26 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Cron]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=184</guid>
		<description><![CDATA[As many have pointed out I am on a backup and disaster recovery kick lately. Some would say that it is about time, others are simply glad to see that data is now being backed up. I have found that it is easiest to zip up files on a local machine prior to moving them [...]]]></description>
			<content:encoded><![CDATA[<p>As many have pointed out I am on a backup and disaster recovery kick lately.  Some would say that it is about time, others are simply glad to see that data is now being backed up.  I have found that it is easiest to zip up files on a local machine prior to moving them to a final destination.  So lets get started:</p>
<p>I have multiple Linux servers with many websites on each, as well as database.  So I created a script that simply tar&#8217;s the files, then gzips them with the date in the filename for archiving.</p>
<p>Here is the file named &#8216;backupall.sh&#8217; that I save in a place reachable by the user I will use to schedule this cronjob:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #c20cb9; font-weight: bold;">date</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;############### Backing up files on the system... ###############&quot;</span>
&nbsp;
<span style="color: #007800;">backupfilename</span>=server_file_backup_<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">'+%Y-%m-%d'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----- First do the sql by deleting the old file and dumping the current data -----&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>backup.sql
mysqldump <span style="color: #660033;">--user</span>=mysqluser <span style="color: #660033;">--password</span>=password <span style="color: #660033;">--all-databases</span> <span style="color: #660033;">--add-drop-table</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>backup.sql
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----- Now tar, then zip up all files to be saved -----&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> cvf <span style="color: #000000; font-weight: bold;">/</span>directory<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>store<span style="color: #000000; font-weight: bold;">/</span>file<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${backupfilename}</span>.tar <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>httpd.conf <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>backup.sql <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>trac<span style="color: #000000; font-weight: bold;">/*</span>
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">/</span>directory<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>store<span style="color: #000000; font-weight: bold;">/</span>file<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${backupfilename}</span>.tar
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>directory<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>store<span style="color: #000000; font-weight: bold;">/</span>file<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${backupfilename}</span>.tar
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">666</span> <span style="color: #000000; font-weight: bold;">/</span>directory<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>store<span style="color: #000000; font-weight: bold;">/</span>file<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${backupfilename}</span>.tar.gz
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;############### Completed backing up system... ###############&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">date</span></pre></div></div>

<p><span id="more-184"></span></p>
<p>As you can see by the tar line I am backing up:</p>
<ul>
<li>The home directory so all users data is backed up.</li>
<li>The html directory where all web sites reside.</li>
<li>My subversion(svn) directory where all of my version control repositories reside because losing them would mean losing years of historical data.</li>
<li>My php.ini</li>
<li>The apache configuration file</li>
<li>The sql file with the database backup created earlier in the script.</li>
<li>Last my trac settings, that house all of my project related history.</li>
</ul>
<p>All of these will be saved in a tar file that I then zip using gzip, and store in a directory somewhere.  Finally I then set the files permissions to 666 which allows pretty much any user copy it to another location for remote backup.</p>
<p>You may also notice that I put &#8216;date&#8217; at the beginning and end of the backupall.sh file.  This echos out the date and time so that I can see the time when the job started and ended.</p>
<p>The script above should be saved somewhere, and then executed via CRON.  Here is how I set up my crontab to handle that by using the command &#8220;crontab -e&#8221;. (Alternatively you can use &#8220;crontab -e -u anotheruser&#8221; to have the task added to a user other than the one you are logged on with. Many will add this to the root users crontab.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> backupall.sh</pre></div></div>

<p>This line in the crontab tells CRON to run this script every day at 1:00AM.</p>
<p><strong>Logging the output from CRON to a file.</strong><br />
If I desired to keep a log of the events it would be nice to output the feedback from the backupall.sh to a file and use it as a log.  I can do this by creating a file to use as a log file, and changing the owner of the file to be the cronjob user that is executing backupall.sh:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> backup_log.txt
<span style="color: #c20cb9; font-weight: bold;">chown</span> cronjobuser backup_log.txt</pre></div></div>

<p>And then editing the crontab line to be as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> backupall.sh <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>backup_log.txt <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>Note that the cronjob line above will not append to the log file, but will clear it and then write the current contents to it.  If you wish to append to the file like a true log file you can use >> instead of the single > making the crontab look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> backupall.sh <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>backup_log.txt <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>To see how I remotely backup this file please see my other post at: <a href="http://www.geekyboy.com">Geekyboy.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/184/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup Windows Domain Controller using NTBACKUP via cmd</title>
		<link>http://www.geekyboy.com/archives/169</link>
		<comments>http://www.geekyboy.com/archives/169#comments</comments>
		<pubDate>Fri, 17 Apr 2009 01:55:06 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Scheduled Tasks]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[domain controller]]></category>
		<category><![CDATA[ntbackup]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=169</guid>
		<description><![CDATA[Backing up your servers for disaster recovery these days much include your Domain Controller if you are utilizing a Windows Active Directory to manage your users. To do this is easy using a tool that comes installed on all Windows servers called NTBACKUP. Of course you can launch the GUI by entering NTBACKUP from the [...]]]></description>
			<content:encoded><![CDATA[<p>Backing up your servers for disaster recovery these days much include your Domain Controller if you are utilizing a Windows Active Directory to manage your users.  To do this is easy using a tool that comes installed on all Windows servers called NTBACKUP.  Of course you can launch the GUI by entering NTBACKUP from the run or command line.  However, this does not make automated backup work very well.  So here is the .bat file that I use to execute it via Windows Scheduled tasks:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">echo</span> off
:: variables
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">logfile</span>=D:\backup_log_file.txt
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">%</span>Date<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #666666; font-style: italic;"># # # Backing up system state containing: local Registry, COM+ Class Registration Database, System Boot Files, Certificates(if certificate server installed), Cluster database(if installed), NTDS.DIT, and SYSVOL folder &gt;&gt; %logfile%</span>
ntbackup backup systemstate <span style="color: #000000; font-weight: bold;">/</span>J <span style="color: #ff0000;">&quot;System State Backup Job&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>F <span style="color: #ff0000;">&quot;D:\system_state_backup.bkf&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">%</span>logfile<span style="color: #000000; font-weight: bold;">%</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">%</span>Date<span style="color: #000000; font-weight: bold;">%</span> Backup Completed<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">%</span>logfile<span style="color: #000000; font-weight: bold;">%</span></pre></div></div>

<p>(NOTE: I am doing this backup via an internal network and using a user account that exists on both systems.  Security may dictate that you handle this differently based on your circumstances.)</p>
<p>After the file is executed by Windows Scheduled Tasks you will then be left with a file that is ready to backup somewhere.  I do this by making a copy to another server by using the methods covered in a previous blog post at <a href="http://www.geekyboy.com/archives/160">Windows backup bat script using xcopy</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/169/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows backup bat script using xcopy</title>
		<link>http://www.geekyboy.com/archives/160</link>
		<comments>http://www.geekyboy.com/archives/160#comments</comments>
		<pubDate>Wed, 15 Apr 2009 14:15:25 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Scheduled Tasks]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xcopy]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=160</guid>
		<description><![CDATA[Recently I had the need to create a bat script that could be executed by the Windows Scheduled Tasks. The purpose was to copy files from one server to another as a cheap way to backup files created by MSSQL backing up the databases. Here is the .bat file contents (cleaned up to protect sensitive [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had the need to create a bat script that could be executed by the Windows Scheduled Tasks.  The purpose was to copy files from one server to another as a cheap way to backup files created by MSSQL backing up the databases.  Here is the .bat file contents (cleaned up to protect sensitive data):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">echo</span>
:: variables
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">sourcedrive</span>=D:\
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">backupdrive</span>=\\servername\d$
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">backupcmd</span>=xcopy <span style="color: #000000; font-weight: bold;">/</span>s <span style="color: #000000; font-weight: bold;">/</span>c <span style="color: #000000; font-weight: bold;">/</span>d <span style="color: #000000; font-weight: bold;">/</span>e <span style="color: #000000; font-weight: bold;">/</span>h <span style="color: #000000; font-weight: bold;">/</span>i <span style="color: #000000; font-weight: bold;">/</span>r <span style="color: #000000; font-weight: bold;">/</span>y
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #666666; font-style: italic;"># # # Moving files</span>
<span style="color: #000000; font-weight: bold;">%</span>backupcmd<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #ff0000;">&quot;%sourcedrive%\directory_to_backup&quot;</span> <span style="color: #ff0000;">&quot;%backupdrive%\directory_to_store_backup&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #666666; font-style: italic;"># # Moveing Complete!</span></pre></div></div>

<p>(NOTE: I am doing this backup via an internal network and using a user account that exists on both systems.  Security may dictate that you handle this differently based on your circumstances.)</p>
<p>Notice that for the backupdrive I am calling another Windows server and using the d$.  This would require that the Windows Scheduled Task be executed using a user that is trusted on both machines.  Also you could specify a local directory on the same server if you did not need to copy the files to another server.<br />
<span id="more-160"></span><br />
If I were executing this via Window Scheduled Tasks there is nowhere for me to see what happened, what files were moved, etc.  This can be solved by adding the following line in the variables area specifying a log file to capture all output that would normally be seen via command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bat" style="font-family:monospace;">set logfile=D:\backup_log_file.txt</pre></div></div>

<p>Then I would append &#8220;>> %logfile%&#8221; to the end of each line so that it would be added to the log file.  In addition I could prepend &#8220;%Date%&#8221; after echo on each line to date stamp each line.</p>
<p>Here is what the final file with these two additions would look like:</p>

<div class="wp_syntax"><div class="code"><pre class="bat" style="font-family:monospace;">@echo
:: variables
set sourcedrive=D:\
set backupdrive=\\servername\d$
set backupcmd=xcopy /s /c /d /e /h /i /r /y
set logfile=D:\backup_log_file.txt
&nbsp;
echo %Date% # # # Moving files &gt;&gt; %logfile%
%backupcmd% &quot;%sourcedrive%\directory_to_backup&quot; &quot;%backupdrive%\directory_to_store_backup&quot; &gt;&gt; %logfile%
&nbsp;
echo %Date% # # Moveing Complete! &gt;&gt; %logfile%</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/160/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

