<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.joycebabu.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Joyce Babu</title>
	
	<link>http://www.joycebabu.com</link>
	<description>Read, learn and share.</description>
	<lastBuildDate>Sun, 25 Jul 2010 10:32:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.joycebabu.com/JoyceBabu" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="joycebabu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.joycebabu.com/JoyceBabu" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.live.com/?add=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.joycebabu.com%2FJoyceBabu" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><item>
		<title>View currently running MySQL queries in realtime</title>
		<link>http://www.joycebabu.com/blog/view-currently-running-mysql-queries-in-realtime.html</link>
		<comments>http://www.joycebabu.com/blog/view-currently-running-mysql-queries-in-realtime.html#comments</comments>
		<pubDate>Sun, 18 Jul 2010 08:36:47 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Solr]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=261</guid>
		<description><![CDATA[Sometimes you might want to view MySQL queries as and when they are being executed. This is possible with the MySQL General Query Log. In this post, I try to explain how to use query logging feature to view live running MySQL queries.]]></description>
			<content:encoded><![CDATA[<p>Today I was playing around with <a href="en.wikipedia.org/wiki/Apache_Solr" target="_blank">Apache Solr</a>. I was really impressed by its text searching capability, especially the <a href="http://wiki.apache.org/solr/MoreLikeThisHandler" target="_blank">MoreLikeThis</a> search handler. I wanted to configure the <a href="http://wiki.apache.org/solr/DataImportHandler" target="_blank">DataImportHandler</a> to import data directly from my MySQL database. It was really easy to configure, and I was able to perform a full import quickly. But when I tried to do a delta import, I found that it was not working as expected. Even though I was calling the delta import, it was causing a full import.</p>
<p>You might be wondering  why I am saying all these here. Well, I suspected that the problem was actually because of my SQL query for delta load.  But to be sure, I wanted to see the query being executed by Solr DataImportHandler. As always I turned to Google for assistance, and I finally reached the MySQL documentation on the <a title="General Query Log" href="http://dev.mysql.com/doc/refman/5.1/en/query-log.html" target="_blank">General Query Log</a>. Voila! This was exactly what I wanted. All I had to do was use the &#8211;log=[filename] parameter and all my queries will be logged to the specified log file. Nice, isn&#8217;t it?</p>
<p>Now I have to stop my running MySQL server and restart it with the &#8211;log switch, in addition to the other regular options. But there was a problem, I was not sure of the other required parameters. You can use the ps utility, when the MySQL server is running, to find out the normal parameters.</p>
<p><code>ps -ax | grep mysql</code></p>
<p>For me the output was</p>
<p><em>/usr/local/mysql/bin/mysqld &#8211;basedir=/usr/local/mysql &#8211;datadir=/usr/local/mysql/data &#8211;user=mysql &#8211;pid-file=/usr/local/mysql/data/localhost.pid &#8211;port=3306 &#8211;socket=/tmp/mysql.sock</em></p>
<p>Now shutdown the MySQL server.</p>
<p><code>// On Mac<br />
/Library/StartupItems/MySQLCOM/MySQLCOM stop</code><br />
<code>// For other Linux/Unix variants try<br />
/etc/init.d/mysqld restart<br />
service mysql restart</code></p>
<p>Start mysqld with <em>&#8211;log</em> option</p>
<p><code>/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data --user=mysql  --pid-file=/usr/local/mysql/data/localhost.pid --port=3306  --socket=/tmp/mysql.sock --log=/tmp/query.log</code></p>
<p>The general query log contains lots of irrelevant information. To view the log after filtering out the unwanted details use tail and grep as given below</p>
<p><code>tail -f /tmp/query.log | grep -v Connect | grep -v Quit</code></p>
<p>The amount of information added to the file is quite large. If you are using this on a production server, I recommend turning off the logging once you are done.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=HiU3OrucJ7U:gFpxjeuIpHU:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=HiU3OrucJ7U:gFpxjeuIpHU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=HiU3OrucJ7U:gFpxjeuIpHU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=HiU3OrucJ7U:gFpxjeuIpHU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/HiU3OrucJ7U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/view-currently-running-mysql-queries-in-realtime.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split header and footer into separate files using awk</title>
		<link>http://www.joycebabu.com/blog/split-header-and-footer-into-separate-files-using-awk.html</link>
		<comments>http://www.joycebabu.com/blog/split-header-and-footer-into-separate-files-using-awk.html#comments</comments>
		<pubDate>Tue, 20 Apr 2010 04:51:06 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Shell Scripting]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=249</guid>
		<description><![CDATA[Saving header and footer from a file into separate files using AWK.]]></description>
			<content:encoded><![CDATA[<p>Recently I had to write a shell script to read a file and split it into header and footer. The header and footer were to be saved into different files. At first I decided to write a script to loop through the file and save the content after performing the necessary condition check. But later I decided that this is not the best solution and checked whether there was a single line command for the same. As usual, I found a simple solution to the problem with awk.</p>
<blockquote><p><code>awk '{if (NR == 1)print &gt;&gt; "header.txt"; else print &gt;&gt; "body.txt";}' input.txt</code><br />
<span style="color: #808080;"><em>Where NR is a built-in variable that contains the number of the current record / line,<br />
input.txt is the input file,<br />
header.txt is output file for header,<br />
body.txt is the output file for the remaining content</em></span></p></blockquote>
<p>Awk reads the input file (input.txt) line by line and checks whether the current line is the first line. If so the content is appended ( &gt;&gt; ) to the file header.txt. Else the content is appended to body.txt.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=fHpl1MbSOKM:SAxIH7PuU1I:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=fHpl1MbSOKM:SAxIH7PuU1I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=fHpl1MbSOKM:SAxIH7PuU1I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=fHpl1MbSOKM:SAxIH7PuU1I:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/fHpl1MbSOKM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/split-header-and-footer-into-separate-files-using-awk.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get free sms alerts when your website is down</title>
		<link>http://www.joycebabu.com/blog/get-free-sms-alerts-when-your-website-is-down.html</link>
		<comments>http://www.joycebabu.com/blog/get-free-sms-alerts-when-your-website-is-down.html#comments</comments>
		<pubDate>Sun, 04 Apr 2010 10:21:02 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Downtime]]></category>
		<category><![CDATA[free uptime monitoring services]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Uptime]]></category>
		<category><![CDATA[uptime monitoring services]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[webmaster]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=238</guid>
		<description><![CDATA[Every webmaster wants their websites to have 100% uptime. But the truth is that not even Google is able to ensure that. So the next best thing we can hope for is to be informed whenever a website goes down, so that the necessary actions can be initiated to bring it back online. Unfortunately, it [...]]]></description>
			<content:encoded><![CDATA[<p>Every webmaster wants their websites to have 100% uptime. But the truth is that not even Google is able to <a href="http://blogs.computerworld.com/google_down">ensure</a> <a href="http://www.searchenginejournal.com/googles-downtime-affected-5-of-the-internet/10463/">that</a>. So the next best thing we can hope for is to be informed whenever a website goes down, so that the necessary actions can be initiated to bring it back online. Unfortunately, it is not possible nor viable to constantly monitor your website and check whether it is up or not. Hence we go for uptime monitoring services like <a href="http://www.pingdom.com/">Pingdom</a>, <a href="http://mon.itor.us">Mon.itor.us</a>, <a href="http://basicstate.com">BasicState</a> etc. The best uptime monitoring services charge a premium fee for using their service. Fortunately, the monitoring services mentioned above have a cut down version of their premium service available for free. Most of the times the free service will be limited in frequency of check, alert methods, detailed statistics, number of checks etc. In fact, none of the free uptime monitoring services I had used provided free sms alerts directly. They either require us to pay or use our own sms gateway subscription.</p>
<p>Everything I have mentioned so far might be known to you already. So why put a false title? Well, I am not finished yet. Yes, you can get a free every minute uptime check with free sms notification when your website is down, depending on your location and mobile service provider.</p>
<p>Pingdom is one of the best uptime monitoring services available. I had been their premium subscriber till last month. When my subscription period was about to end, I started looking for an alternative, since I felt I was not using my subscription fully. I was using only one check, and a premium account allowed up to 5 checks. Most of the free service I checked were limited in frequency of checks (max being every 5 mins). Finally I came across <a href="http://twitter.com/pingdom">Pingdom&#8217;s twitter account</a> and found that they were offering free accounts with one every min check. There was also 20 free sms credits available with the account. What happens once that is over? Their alert methods also includes sending direct messages to your Twitter account. Now twitter allows sms updates for tweets from people you follow. By setting up Direct Message alert in Pingdom and following <a href="http://twitter.com/pingdomalert">PingdomAlert</a> on Twitter with sms alerts turned on, you can get unlimited free sms alerts when your website is down.</p>
<p><strong>Disclaimer:</strong><br />
When you are depending on two services, it is possible that problem with any of providers can cause delay&#8217;s and reduce the overall effectiveness of the system. Even if Pingdom sends the alert within a minite, there is no guarantee that twitter will send the sms alert on time. If you have a critical application, do not rely on such an unreliable setup and go for a premium subscription. When I checked, I got sms notifications within 1 min of receiving a Direct Message. Also, sms check is not much important for me since I have my mailbox open most of the time, and usually detect downtimes within 5 mins from email alerts. Your case might be different, so use at your own risk.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=ymmDLeVOTXo:w0GtCrUBaSY:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=ymmDLeVOTXo:w0GtCrUBaSY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=ymmDLeVOTXo:w0GtCrUBaSY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=ymmDLeVOTXo:w0GtCrUBaSY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/ymmDLeVOTXo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/get-free-sms-alerts-when-your-website-is-down.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Enabling gzip compression if mod_deflate is not enabled</title>
		<link>http://www.joycebabu.com/blog/enabling-gzip-compression-if-mod_gzip-is-not-enabled.html</link>
		<comments>http://www.joycebabu.com/blog/enabling-gzip-compression-if-mod_gzip-is-not-enabled.html#comments</comments>
		<pubDate>Wed, 06 Jan 2010 17:54:45 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[hostgator]]></category>
		<category><![CDATA[mod_gzip]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=217</guid>
		<description><![CDATA[Enabling gzip support on server without using mod_deflate or mod_gzip Apache module. The technique uses PHP with Gzip support for compressing the files.]]></description>
			<content:encoded><![CDATA[<p>Today I saw a tweet by my friend <a href="http://www.diovo.com/" target="_blank">Niyas</a> that Host Gator does not support <em>mod_gzip</em>. This made me wonder whether it is possible to achieve this using PHP. I contacted HostGator support and confirmed that GZip support for PHP is enabled on both shared and dedicated hosting accounts, whereas <em>mod_deflate</em> Apache module is available only for dedicated hosting customers. Fortunately, we can use PHP to compress files on the fly.</p>
<p>Enabling gzip compression in an existing PHP file is very simple. Add the following line at the beginning of the file (it should appear before any output statement).</p>
<pre><code>&lt;?php
ob_start ("ob_gzhandler");
?&gt;</code></pre>
<p>Very simple, right? But what if we have hundreds of files to edit? Don&#8217;t worry, there is solution for that too. We can use the PHP configuration variable <strong><code><em>auto_prepend_file</em></code></strong> to automatically include the above code at the beginning of all PHP files. Copy the above code to a file named prepend.php and place it at the root of your website (<em>~/public_html</em> in CPanel, <em>~/httpdocs</em> in Plesk).</p>
<p>Now we are going to automatically include the above file at the beginning of all PHP files using <em><code>auto_prepend_file</code></em>. Depending on how PHP is configured on your server, the steps for modifying the PHP configuration variable is also different.</p>
<p>If PHP is configured in CGI/FastCGI mode (HostGator uses this mode), we will be using <em>php.ini</em> file to make the above change. Create a file named <em>php.ini</em> at the root of your website and copy the following code into it. If the file already exists, append it to the end of the file.</p>
<pre><code>auto_prepend_file=&lt;full-path-to-document-root&gt;/prepend.php</code></pre>
<p>If PHP is loaded as apache module (<em>mod_php</em>), we will have to use <em>.htaccess</em> to achieve the same effect. Create a file named <em>.htaccess</em> at the web root and copy the following code into it. If the file exists, append at the end of the file.</p>
<pre><code>php_value auto_prepend_file &lt;full-path-to-document-root&gt;/prepend.php</code></pre>
<p>In both methods, replace <em>&lt;full-path-to-document-root&gt;</em> with the full path to your website root directory, for example <em>/home/joyce/public_html.</em></p>
<p>Now the <em>prepend.php</em> file is automatically included by the PHP interpreter, whenever a PHP file is requested. But this method (as of now) does not work for non PHP files like HTML, CSS, JavaScript etc, which should also be compressed. This is because these files are handled directly by Apache and is not passed to the PHP interpreter. To ensure that these files are also compressed, we have to instruct Apache to pass these files to the PHP interpreter before sending them to the browser. For this, lets once again go back to <em>.htaccess</em>. Append the following code at the end of your <em>.htaccess</em> file (create one, if you don&#8217;t have  it already).</p>
<pre><code>&lt;FilesMatch "\.(htm|html|css|js)"&gt;
	ForceType application/x-httpd-php
&lt;/FilesMatch&gt;
</code></pre>
<p>The above code instructs Apache that files ending with .<em>js</em>, .<em>htm</em>, .<em>html</em>, <em>.css </em>and .<em>js</em> extensions are also PHP files and should be passed through PHP interpreter. The only problem remaining is that Content-type header for all files have been changed to text/html. To fix this we need to check the requested file-name and set the correct Content-type header depending on the file extension. In order to do this, open <em>prepend.php</em> and replace the current code with</p>
<pre><code>&lt;?php
// Start output buffering
ob_start ("ob_gzhandler");

// Set the correct content type header depending on filename
$arContentType = array('htm' =&gt; 'text/html', 'html' =&gt; 'text/html', 'css' =&gt; 'text/css', 'js' =&gt; 'text/javascript');
if(strpos($_SERVER['REQUEST_URI'], '.') !== FALSE){
	$ext = explode('.', $_SERVER['REQUEST_URI']);
	$ext = array_pop($ext);
	if(($pos = strpos($ext, '?')) !== FALSE){
		$ext = substr($ext, 0, $pos);
	}
	if(isset($arContentType[$ext])){
		header ("Content-type: {$arContentType[$ext]}; charset: UTF-8");
	}
}

// You can also set expiration headers in this file
?&gt;
</code></pre>
<p>That&#8217;s all Folks. You have successfully enabled Gzip compression on your server without using any Apache modules.</p>
<p>This is a working code. But I have tested it only with <em>mod_php</em> configuration. You have to be very careful when enabling PHP code in JS/CSS files. There may be many flaws in this code. If you find any, please let me know. We can further improve this code by adding expiration and cache headers to enable client side caching.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=y-T8qkStXS4:H0KiZj1YvSw:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=y-T8qkStXS4:H0KiZj1YvSw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=y-T8qkStXS4:H0KiZj1YvSw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=y-T8qkStXS4:H0KiZj1YvSw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/y-T8qkStXS4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/enabling-gzip-compression-if-mod_gzip-is-not-enabled.html/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Apple to fight Google back?</title>
		<link>http://www.joycebabu.com/blog/apple-to-fight-google-back.html</link>
		<comments>http://www.joycebabu.com/blog/apple-to-fight-google-back.html#comments</comments>
		<pubDate>Tue, 05 Jan 2010 19:58:54 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[ad]]></category>
		<category><![CDATA[admob]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=207</guid>
		<description><![CDATA[Apple buys Mobile Ad company Quattro.]]></description>
			<content:encoded><![CDATA[<p>The past year has seen Google increasingly becoming a rival of Apple. The competition between the two companies have been growing with the intrusion of Google into fields ruled by Apple. It began with Android and expanded through Google Chrome and Chrome OS. This led to the resignation of Google CEO Eric Schmidt from Apple&#8217;s Board of Directors. Now with the <a href="http://www.joycebabu.com/blog/nexus-one-released-not-available-in-india.html">release of the new Google Phone (Nexus One)</a>, the two companies have become direct competitors.</p>
<p>It looks like Apple has finally decided to fight back by entering Google&#8217;s arena with the <a href="http://bits.blogs.nytimes.com/2010/01/05/apple-is-said-to-buy-mobile-ad-company/?src=twt&amp;twt=nytimes" target="_blank">acquisition of the mobile ad company Quattro</a>. Google had recently acquired AdMob, a four year old ad network, which had risen to be one of the most important players in the Mobile Ad industry. The deal is under scrutiny by the U.S. regulators. There were rumors that Apple also wanted to buy AdMob, but was out-bidden by Google.</p>
<p>The acquisition also puts Apple in direct competition with other companies like Microsoft and Yahoo.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=M130-DIGeuY:h-BuASGP9v8:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=M130-DIGeuY:h-BuASGP9v8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=M130-DIGeuY:h-BuASGP9v8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=M130-DIGeuY:h-BuASGP9v8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/M130-DIGeuY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/apple-to-fight-google-back.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nexus One released. Not available in India</title>
		<link>http://www.joycebabu.com/blog/nexus-one-released-not-available-in-india.html</link>
		<comments>http://www.joycebabu.com/blog/nexus-one-released-not-available-in-india.html#comments</comments>
		<pubDate>Tue, 05 Jan 2010 19:03:10 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[nexus one]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=195</guid>
		<description><![CDATA[Nexus One, the Google Phone, has been officially released.]]></description>
			<content:encoded><![CDATA[<p>The waiting has come to an end. The Google Phone a.k.a Nexus one has been finally released. Official webpage of the phone at <a href="http://www.google.com/phone/">www.google.com/phone</a> has also gone live.</p>
<p>Technical specifications of the phone can be found <a href="www.google.com/phone/static/en_US-nexusone_tech_specs.html">here</a>. The device designed by Google and built by HTC is powered by a 1GHz Snapdragon processor and 512MB of ROM &amp; 512MB of RAM. It includes features like GPS, accelerometer, proximity sensor, a 5 mega pix camera with LED flash and an additional microphone for noise cancellation. With a weight of 130 gms and a thickness of 11.5mm, Google boasted that the handset is no thicker than a number two pencil, and no heavier than a Swiss Army knife.</p>
<p>Unfortunately, the phone is not available in India. I see the following message when visiting the official webpage</p>
<blockquote><p>Sorry, the Nexus One phone is not available in your country.</p></blockquote>
<p>According to the <a href="https://www.google.com/phone/choose?locale=en_US&amp;s7e=">sales</a> page of the phone, Nexus One is currently available only in the U.S. The phone is available for a contract free price of $529 or a subsidized rate of $179 on a two year contract with T-Mobile. The page says that the Google phone will be available in US from Verizon wireless and in Europe from Vodafone in spring 2010.</p>
<p>The phone can be personalized with a two line engraving at the back of the phone.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=1bk7I_4vge0:hY7S5NVe-GI:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=1bk7I_4vge0:hY7S5NVe-GI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=1bk7I_4vge0:hY7S5NVe-GI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=1bk7I_4vge0:hY7S5NVe-GI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/1bk7I_4vge0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/nexus-one-released-not-available-in-india.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nexus one to be launched tomorrow</title>
		<link>http://www.joycebabu.com/blog/nexus-one-to-be-launched-tomorrow.html</link>
		<comments>http://www.joycebabu.com/blog/nexus-one-to-be-launched-tomorrow.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 11:57:22 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google phone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[nexusone]]></category>
		<category><![CDATA[phone]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=181</guid>
		<description><![CDATA[Google's new mobile phone "Nexus One" powered by Android is to be released tomorrow.]]></description>
			<content:encoded><![CDATA[<p>Ever since some Google employees tweeted about a Google Phone a.k.a NexusOne, the tech world is abuzz with rumors about the phone. Many established news source, possible with inside help, have announced that the new phone is designed by Google and manufactured by HTC. There are several videos of the phone in action on YouTube. GSMArena has posted <a href="http://www.gsmarena.com/htc_google_nexus_one-3069.php">technical specification of the phone</a>. The phone is said to have 512 MB RAM and a 1GHz processor.</p>
<p>Hopefully, after almost a month of anticipation, the wait is finally getting over. Google has called for an &#8220;Android Press Gathering&#8221; tomorrow. Everyone believe that the new phone will be announced at the press meet.</p>
<p>Encouraged by Google&#8217;s regular practice, I checked the page <a href="http://www.google.com/phone">www.google.com/phone</a> and found that the page is different from the <a href="http://www.google.com/asdf">standard Google 404 page</a>. Which suggests that there is something going on there. So keep checking the url as it may be official page of the Google phone, once it is released.</p>
<p><strong>Update:</strong> Engadget has posted a <a href="http://www.engadget.com/2010/01/02/exclusive-google-nexus-one-hands-on-video-and-first-impressio/">review of Nexus One</a>.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=MCFZwpzdUPU:3U6e3rAWDgM:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=MCFZwpzdUPU:3U6e3rAWDgM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=MCFZwpzdUPU:3U6e3rAWDgM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=MCFZwpzdUPU:3U6e3rAWDgM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/MCFZwpzdUPU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/nexus-one-to-be-launched-tomorrow.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving wget file with different filename</title>
		<link>http://www.joycebabu.com/blog/saving-wget-file-with-different-filename.html</link>
		<comments>http://www.joycebabu.com/blog/saving-wget-file-with-different-filename.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 11:05:44 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=175</guid>
		<description><![CDATA[Anyone who has worked with Linux must be familar with the wget utility. wget utility allows you to download files from a remote server using HTTP, HTTPS and FTP protocols. Downloading files using wget is as simple as wget http://www.joycebabu.com/my-photo.jpg Where http://www.joycebabu.com/my-photo.jpg is the file to be downloaded. By default wget saves the file with [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has worked with Linux must be familar with the <em>wget </em>utility. <em>wget </em>utility allows you to download files from a remote server using HTTP, HTTPS and FTP protocols. Downloading files using <em>wget </em>is as simple as</p>
<blockquote><p><code>wget http://www.joycebabu.com/my-photo.jpg</code><br />
<span style="color: #888888;"><em>Where http://www.joycebabu.com/my-photo.jpg is the file to be downloaded.</em></span></p></blockquote>
<p>By default <em>wget </em>saves the file with the same name as the fetched file. For example, the above command will save the file as <em>my-photo.jpg</em> in the current working directory. If a file already exists with the given name, the downloaded file will be named as <em>my-photo.jpg.1</em>, <em>my-photo.jpg.2</em> etc until a non existent filename is found.</p>
<p>It is possible to explicitly specify a different name for the downloaded file. This is possible using the <code>-O</code> switch (<code>--output-document</code> also works, but I believe short is sweet). The new command is</p>
<blockquote><p><code>wget -O photo.jpg http://www.joycebabu.com/my-photo.jpg</code><br />
<span style="color: #888888;"><em>Where photo.jpg is the new filename.</em></span></p></blockquote>
<p><strong>But be careful while using the <code>-O</code> switch. If there is an existing file with the same name, it will be overwritten with the new file.</strong></p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=3xMerU-WJcA:lRJQN1fIlX0:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=3xMerU-WJcA:lRJQN1fIlX0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=3xMerU-WJcA:lRJQN1fIlX0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=3xMerU-WJcA:lRJQN1fIlX0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/3xMerU-WJcA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/saving-wget-file-with-different-filename.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying multiple files simultaneously using scp utility</title>
		<link>http://www.joycebabu.com/blog/copying-multiple-files-with-scp.html</link>
		<comments>http://www.joycebabu.com/blog/copying-multiple-files-with-scp.html#comments</comments>
		<pubDate>Fri, 01 Jan 2010 15:45:01 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[copy files]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[multiple files]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[secure copy]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=155</guid>
		<description><![CDATA[How to copy multiple files using the Secure Copy (scp) utility.]]></description>
			<content:encoded><![CDATA[<p>Happy New Year to all.</p>
<p>I have been using the Secure Copy (scp) utility for copying files between my local server and development server. Sometimes I have to copy more than one file. Previously I used to copy the files one at a time. This is very annoying, as you have to type the password every time you use the command . But it is possible to copy multiple files using scp, just like the copy (cp) utility.</p>
<p>When you have to copy multiple files to your remote server, the syntax is similar to the cp command.</p>
<blockquote><p><code>scp file1.sql file2.sh joyce@joycebabu.com:~/upload</code></p></blockquote>
<p>Where file1.sql and file2.sh are the files to be copied, joyce is the username, joycebabu.com is the hostname and ~/upload is the destination directory on the remote server.</p>
<p>In order to download multiple files from the remote server, the command to be used is</p>
<blockquote><p><code>scp joyce@joycebabu.com:"file1.log file2.log" ~/logs</code></p></blockquote>
<p>Where file1.log and file2.log are the files to be downloaded and ~/logs is the destination directory on the local server. Notice the quotes around the filenames. This ensures that the filenames list is not parsed by the local shell and is passed to the remote shell. Similarly, when you want to download files using wildcards (*.php, files_?.log etc), you should enclose the name within quotes to ensure that the expansion is done by the remote server.</p>
<p>The -r option can be used to copy directories recursively.</p>
<blockquote><p><code>scp -r joyce@joycebabu.com:~/logs ~/logs</code></p></blockquote>
<p>This may not be a lifesaver tip and the time gained by this method may be small. After all, when a large number of files are to be transferred, I use FTP or tar my files and copy it. But at times when things go wrong, even this small gain can help.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=d25uPzyOnH0:KZ-HH1t3VO8:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=d25uPzyOnH0:KZ-HH1t3VO8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=d25uPzyOnH0:KZ-HH1t3VO8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=d25uPzyOnH0:KZ-HH1t3VO8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/d25uPzyOnH0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/copying-multiple-files-with-scp.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extract single table from a mysql dump</title>
		<link>http://www.joycebabu.com/blog/extract-single-table-from-a-mysql-dump.html</link>
		<comments>http://www.joycebabu.com/blog/extract-single-table-from-a-mysql-dump.html#comments</comments>
		<pubDate>Wed, 15 Jul 2009 17:27:12 +0000</pubDate>
		<dc:creator>Joyce</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[Extract Table]]></category>
		<category><![CDATA[Grep]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Backup]]></category>
		<category><![CDATA[Sed]]></category>

		<guid isPermaLink="false">http://www.joycebabu.com/?p=144</guid>
		<description><![CDATA[Extracting single table from a huge mysqldump file using unix shell commands.]]></description>
			<content:encoded><![CDATA[<p>The other day, while working with the MySQL database of one of my sites, I accidentally damaged one of the tables irrecoverably. Fortunately, I was using <a href="http://sourceforge.net/projects/automysqlbackup/" target="_blank">AutoMySQLBackup</a> script to backup all my databases at 12 AM every day. To save time, I decided to import only the damaged table. But when I tried to open the .sql file created by the mysqldump program, I understood that it was not going to as easy as I thought. The dump file was over 100 MB in size and  none of my text editors allowed me to open a file of that size.</p>
<p>As usual, I approached Google for a solution and it introduced me to two different solutions &#8211; AWK (a programming language) and Sed (a unix utility). There is only a very slight difference between the two commands.</p>
<blockquote><p>awk &#8216;/&#8211; Table structure for table .tbl_first./,/&#8211; Table structure for table .tbl_second./{print}&#8217; mydumpfile.sql &gt; mytable.sql</p>
<p>sed -ne &#8216;/&#8211; Table structure for table .tbl_first./,/&#8211; Table structure for table .tbl_second./p&#8217; mydumpfile.sql &gt; mytable.sql</p></blockquote>
<p>Here <em>tbl_first</em> is the table I wanted to extract and <em>tbl_second</em> was the table below that. The above commands will search the file <em>mydumpfile.sql</em> and extract the text between the start string (<em>&#8211; Table structure for table .tbl_first.</em>) and end string (<em>&#8211; Table structure for table .tbl_second.).</em> The dots before and after the table name are wildcard character to match the engrave character, which has a special meaning in shell commands. The {print} option (p in sed) prints the extracted string, which is then redirected to the file <em>mytable.sql</em>.</p>
<p>But that didn&#8217;t solve my problem completely. I was not sure of the order of tables in the .sql file. This time  <em>grep</em> (another powerful unix utility) came to my rescue. The following command lists all the tables in the file <em>mydumpfile.sql</em> in the same order in which they appear in the file.</p>
<blockquote><p>grep &#8216;Table structure&#8217; mydumpfile.sql | cut -d&#8217;`&#8217; -f2</p></blockquote>
<p>I don&#8217;t know a lot about shell commands. But with my very limited experience I can say that they are extremely powerful. Two small lines of code saved me a lot of time.</p>
<div class="feedflare">
<a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:wF9xT3WuBAs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=--gIMfXUzP0:f7C2Uikua7E:wF9xT3WuBAs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=--gIMfXUzP0:f7C2Uikua7E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.joycebabu.com/~ff/JoyceBabu?a=--gIMfXUzP0:f7C2Uikua7E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/JoyceBabu?i=--gIMfXUzP0:f7C2Uikua7E:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JoyceBabu/~4/--gIMfXUzP0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.joycebabu.com/blog/extract-single-table-from-a-mysql-dump.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
