<?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>Kudithipudi.Org &#187; Programming</title>
	<atom:link href="http://kudithipudi.org/category/technology/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://kudithipudi.org</link>
	<description>Too much time on hand!!!</description>
	<lastBuildDate>Tue, 22 May 2012 13:11:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Project PaaS : Day 2 on Google App Engine</title>
		<link>http://kudithipudi.org/2012/05/03/project-paas-day-2-on-google-app-engine/</link>
		<comments>http://kudithipudi.org/2012/05/03/project-paas-day-2-on-google-app-engine/#comments</comments>
		<pubDate>Fri, 04 May 2012 04:31:14 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[google app engine]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=1424</guid>
		<description><![CDATA[It looks like I was able to accomplish writing the application that I wanted to on the App Engine in 2 days!!  at least in it&#8217;s basic form.  After some help from Google, I updated the application I created yesterday (http://samurai-apps.appspot.com/) to display the User Agent string being sent by the client. The code has [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like I was able to accomplish writing the <a href="http://kudithipudi.org/2012/05/01/2012-may-project/">application</a> that I wanted to on the App Engine in 2 days!!  at least in it&#8217;s basic form.  After some help from Google, I updated the application I created yesterday (<a href="http://samurai-apps.appspot.com/">http://samurai-apps.appspot.com/</a>) to display the User Agent string being sent by the client.</p>
<p>The code has been updated to github at <a href="https://github.com/kudithipudi/google-app-engine/">https://github.com/kudithipudi/google-app-engine/</a></p>
<p>Lessons from day 2?</p>
<ul>
<li>Python doesn&#8217;t like tabs <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Always use spaces to ident. I was using Notepad++ as the editor and it automatically puts tabs when you hit enter. Why? Looks like that is the best practice according to this style guide (<a href="http://www.python.org/dev/peps/pep-0008/">http://www.python.org/dev/peps/pep-0008/</a>)</li>
<li>The &#8220;Logs&#8221; console in the SDK toolkit should be your best friend. It let&#8217;s you know if there is any error in your code and what line it believes the error is at.</li>
</ul>
<p>Next, I will try to pretty it up a bit.</p>
<p>Isn&#8217;t it amazing that I was able to create a simple app in a matter of 2 days and host it on an &#8220;infinitely&#8221; scalable  platform without even taking our my credit card.</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2012/05/03/project-paas-day-2-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project PaaS : Day 1 on Google App Engine</title>
		<link>http://kudithipudi.org/2012/05/02/project-paas-day-1-on-google-app-engine/</link>
		<comments>http://kudithipudi.org/2012/05/02/project-paas-day-1-on-google-app-engine/#comments</comments>
		<pubDate>Thu, 03 May 2012 03:35:41 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[google app engine]]></category>
		<category><![CDATA[paas]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=1421</guid>
		<description><![CDATA[Following up on my public resolution for his month..I started playing with Google App engine. I think a lot has been written about what it is and how it works, but in a nutshell, think of it as an environment to deploy your applications and not have to worry about underlying system capacity. It provides [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my <a href="http://kudithipudi.org/2012/05/01/2012-may-project/">public</a> resolution for his month..I started playing with <a href="https://appengine.google.com/">Google App engine</a>. I think a lot has been written about <a href="https://developers.google.com/appengine/">what it is and how it works</a>, but in a nutshell, think of it as an environment to deploy your applications and not have to worry about underlying system capacity. It provides support for <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a>, <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> and more recently Google&#8217;s own <a href="http://en.wikipedia.org/wiki/Go_%28programming_language%29">Go</a> programming languages.</p>
<p>I chose Python, since I have been <a href="http://kudithipudi.org/2012/03/0/how-to-clear-screen-based-on-os-in-python-scripts/">meaning</a> to dabble in it for a while now. So without further adieu, here is a link to my first application on Google App Engine</p>
<p><a href="http://samurai-apps.appspot.com/">http://samurai-apps.appspot.com/</a></p>
<p>And obviously it has to be hello world <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>How did I get here?</p>
<ol>
<li>As any good programmer would do, I first tried to find a good place to store my source code. I chose Github, since it seems to be the goto place for hackers (in the good sense <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) in recent times. I opened a free account on it and created a repository called google-app-engine at <a href="https://github.com/kudithipudi/google-app-engine/">https://github.com/kudithipudi/google-app-engine/</a> .</li>
<li>Following instructions listed here <a href="https://developers.google.com/appengine/docs/python/gettingstartedpython27/">https://developers.google.com/appengine/docs/python/gettingstartedpython27/</a> and created the helloworld script.</li>
<li>Enabled App Engine on my account by validating myself. Had to use my mobile phone to do the validation.</li>
<li>Created an app called samurai-apps in the Google App Engine control panel</li>
<li>Deployed the helloworld script to the Google Apple engine using the deploy function in the SDK tool. (note: make sure that the name of the app you create in the SDK is the same as the one you created in the app engine control panel. Or you will get an error stating &#8220;This application does not exist (app_id=u&#8217;xxx&#8217;).&#8221; where  xxx is the name of the app in the SDK tool)</li>
</ol>
<p>Pretty simple eh.. <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now the challenge is to program something more useful than print hellworld <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2012/05/02/project-paas-day-1-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO : Sync git clients across workstations using dropbox</title>
		<link>http://kudithipudi.org/2012/04/15/how-to-sync-git-clients-across-workstations-using-dropbox/</link>
		<comments>http://kudithipudi.org/2012/04/15/how-to-sync-git-clients-across-workstations-using-dropbox/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 02:47:38 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=1368</guid>
		<description><![CDATA[I have recently started using git as a source control for the various scrips that I write. As I also mentioned in this post, I use dropbox to synchronize my data across workstations. Here is my setup for synchronizing git clients across multiple workstations using the same SSH keys (note: this is not a recommended setup from a security [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently started using git as a source control for the various scrips that I write. As I also mentioned in this <a href="http://kudithipudi.org/2011/11/13/how-to-move-your-life-into-the-cloud/">post</a>, I use dropbox to synchronize my data across workstations. Here is my setup for synchronizing git clients across multiple workstations using the same SSH keys (<strong>note</strong>: this is not a recommended setup from a security prospective. you are recommended to generate different SSH key pairs per workstation to ensure one key getting lost doesn&#8217;t compromise your entire account).</p>
<ol>
<li>Workstation 1</li>
<ol>
<li>create a directory under your dropbox root, that you want to use as your git home directory. Say DROPBOX/git</li>
<li>Install Git for Windows, or whatever git client you want to use</li>
<li>Change the home path on the git client by executing
<pre class="brush: plain; title: ; notranslate">HOME='PATH_TO_DROPBOX/DROPBOX/git' </pre>
</li>
<li>Check if the home path has been changed by executing
<pre class="brush: plain; title: ; notranslate">echo $HOME</pre>
</li>
<li>Create your SSH keys and configure your public key on the git server</li>
</ol>
<li>Workstation 2</li>
<ol>
<li>Repeat and rinse step 1 &#8211; 4 specified for workstation 1. You don&#8217;t need to create the SSH keys since the other clients will recognize the keys that dropbox would have synced up.</li>
</ol>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2012/04/15/how-to-sync-git-clients-across-workstations-using-dropbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO : Clear screen based on OS in python scripts</title>
		<link>http://kudithipudi.org/2012/03/08/how-to-clear-screen-based-on-os-in-python-scripts/</link>
		<comments>http://kudithipudi.org/2012/03/08/how-to-clear-screen-based-on-os-in-python-scripts/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 14:59:46 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=1209</guid>
		<description><![CDATA[I like shiny new toys . Even though perl is pretty powerful and more than enough for the simple tasks I get to automate from time to time, I want to start learning python and find out first hand, why the whole geek community is raving about it. As I start to write new scripts [...]]]></description>
			<content:encoded><![CDATA[<p>I like shiny new toys <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Even though <a href="http://perl.org">perl</a> is pretty powerful and more than enough for the simple tasks I get to automate from time to time, I want to start learning <a href="http://python.org">python</a> and find out first hand, why the whole geek community is raving about it.</p>
<p>As I start to write new scripts in python, I wanted to document how I used to do some things in perl and how I implemented them in python.</p>
<p>One of the standard features of any script I write is to &#8220;clear&#8221; the screen before starting to send output to the console. Here is the comparison between perl and python</p>
<h4>perl</h4>
<pre class="brush: plain; title: ; notranslate">system $^O eq 'MSWin32' ? 'cls' : 'clear'; </pre>
<h4>python</h4>
<pre class="brush: plain; title: ; notranslate">

# Clear screen, based on the OS
if (os.name == 'nt'):
os.system(&quot;cls&quot;)
else:
os.system(&quot;clear&quot;)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2012/03/08/how-to-clear-screen-based-on-os-in-python-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demonstrating the power of perl</title>
		<link>http://kudithipudi.org/2012/03/01/demonstrating-the-power-of-perl/</link>
		<comments>http://kudithipudi.org/2012/03/01/demonstrating-the-power-of-perl/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 06:26:05 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=1185</guid>
		<description><![CDATA[I haven&#8217;t scripted in perl for quite some time (disadvantages of moving into management ). Today, we had to analyze some log files at work and thought I would dust off my scripting skills.. The source data is Apache web logs and we had to find out the number of hits from a unique IP [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t scripted in perl for quite some time (<del>dis</del>advantages of moving into management <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). Today, we had to analyze some log files at work and thought I would dust off my scripting skills..</p>
<p>The source data is Apache web logs and we had to find out the number of hits from a unique IP address for a particular scenario.</p>
<p>Pretty simple right, grep will do the job very well. As demonstrated in this <a href="http://kudithipudi.org/2012/02/29/how-to-sort-apache-web-logs-for-hits-by-unique-ip-addresses/">blog post</a>. But we had to analyze the data for a ton of servers and I really didn&#8217;t want to repeat the same command again and again. Did you know that laziness is the mother of invention <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . So I wrote a simple perl script to do the job for me. The biggest advantage of writing this perl script was not that it helped reduce the copy/paste job, but the speed that the script took to run. Details of the comparison below</p>
<h3>HOW 99% OF ENGINEERS WOULD DO IT<strong></strong></h3>
<p>The analysis consisted of getting web logs for the last week (and some of these log files were already rotated/compressed). Concatenating them to create one large file and then getting the number of hits by IP for a certain condition. This can be done very simply by using a couple of commands that come standard with any *nix system</p>
<ul>
<li>cp</li>
<li>cat</li>
<li>grep for each day we needed the data</li>
</ul>
<p>The final grep command would look like this</p>
<pre class="brush: plain; title: ; notranslate"> grep -i &quot;\[20/Feb/2012&quot; final_log | grep -i &quot;splash.do&quot; | grep -i productcode | cut -d' ' -f 1 -| sort |uniq -c | sort -rn &gt; ~/2_20_2012_ip_report.log </pre>
<p>Timing this command showed that it took <strong><span style="color: #ff0000;">~1 min and 22</span></strong> seconds to run it.</p>
<h3><strong>HOW THE 1% DO IT:)</strong></h3>
<p>I wrote this perl script (disclaimer : I am not a programmer <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , so pls excuse the hack code).</p>
<pre class="brush: plain; title: ; notranslate">

#!/usr/bin/perl
# Modules to load
# use strict;
use warnings;

# Variables
my $version = 0.1;

# Clear the screen
system $^O eq 'MSWin32' ? 'cls' : 'clear';

# Create one large file to parse
`cp /opt/apache/logs/access_log ~/access_log`;
`cp /opt/apache/logs/access_log.1.gz ~/access_log.1.gz`;
`cp /opt/apache/logs/access_log.2.gz ~/access_log.2.gz`;

`gunzip access_log.1.gz`;
`gunzip access_log.2.gz`;

`cat access_log.2 access_log.1 access_log &gt; final_access_log`;

# Hostname
$hostName=`hostname`;
chomp($hostName);

print &quot;The Hostname of the server is : $hostName \n&quot;;

# Process the log file file, one line at a time
open(INPUTFILE,&quot;&lt; final_access_log&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;

while (defined ($line = &lt;INPUTFILE&gt;)) {
 chomp $line;
 if ($line =~ m/\[20\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_20_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[21\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_21_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[22\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_22_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[23\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_23_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[24\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_24_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[25\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_25_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }

if ($line =~ m/\[26\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_26_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[27\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_27_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
 if ($line =~ m/\[28\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; 2_28_2012_log_file&quot;) || die &quot;Couldn't open log file, exiting $!\n&quot;;
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
}

`rm final_access_log`;
`rm access_log`;
`rm access_log.1`;
`rm access_log.2`;

for ($day=0; $day &lt; 9; $day++)
 {
 $outputLog = $hostName.&quot;_2_2&quot;.$day.&quot;_2012.txt&quot;;
 $inputLog = &quot;2_2&quot;.$day.&quot;_2012_log_file&quot;;

$dateString = &quot;\\[2&quot;.$day.&quot;/Feb/2012&quot;;

print &quot;Running the aggregator with following data\n&quot;;
 print &quot;Input File : $inputLog\n&quot;;
 print &quot;Output Log : $outputLog\n&quot;;
 print &quot;Date String: $dateString\n&quot;;

`grep -i &quot;splash.do&quot; | grep -i productcode | cut -d' ' -f 1 -| sort |uniq -c | sort -rn &gt; ~/$outputLog`;

# Cleanup after yourself
 `rm $inputLog`;
 }
</pre>
<p>I wrote a smaller script to do the same job as the command line hack that I tried earlier and compared the time. First, here is the smaller script</p>
<pre class="brush: plain; title: ; notranslate">

#!/usr/bin/perl
# Modules to load
# use strict;
use warnings;

# Variables
my $version = 0.1;
# Clear the screen
system $^O eq 'MSWin32' ? 'cls' : 'clear';
open (TEMPFILE,&quot;&lt; final_log&quot;);

# Match date and write to another log file
while (defined ($line = &lt;TEMPFILE&gt;)) {
 chomp $line;
 if ($line =~ m/\[20\/Feb\/2012/)
 {
 open(OUTPUTFILE, &quot;&gt;&gt; perl_speed_test_output.log&quot;);
 print OUTPUTFILE &quot;$line\n&quot;;
 close(OUTPUTFILE);
 next;
 }
}

`grep -i &quot;splash.do&quot; perl_speed_test_output.log | grep -i productcode | cut -d' ' -f 1 -| sort |uniq -c | sort -rn &gt; ~/perl_speed_test_output_ip.log`;
</pre>
<p>Timing this script, showed that it took <span style="color: #008000;"><strong>21</strong></span> seconds to run it.  &gt; 300% improvement in speed and more importantly, less load (RAM utilization) on the system</p>
<p>One has to love technology <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2012/03/01/demonstrating-the-power-of-perl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HOW TO : for loop in bash</title>
		<link>http://kudithipudi.org/2011/06/23/how-to-for-loop-in-bash/</link>
		<comments>http://kudithipudi.org/2011/06/23/how-to-for-loop-in-bash/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 16:54:30 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=977</guid>
		<description><![CDATA[Quick post for my own reference down the road. the &#8220;for&#8221; loop comes in very handy, when you want to perform the same task on multiple items in a bash shell. For example, I wanted to query the DNS results of a couple of sub domains (blog.gogoair.com, pr.gogoair.com, tracker.gogoair.com), I can do it the normal [...]]]></description>
			<content:encoded><![CDATA[<p>Quick post for my own reference down the road. the &#8220;for&#8221; loop comes in very handy, when you want to perform the same task on multiple items in a bash shell.</p>
<p>For example, I wanted to query the DNS results of a couple of sub domains (blog.gogoair.com, pr.gogoair.com, tracker.gogoair.com), I can do it the normal way (that 99% of us do <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<pre class="brush: plain; title: ; notranslate"> dig blog.gogoair.com

dig pr.gogoair.com

dig tracker.gogoair.com </pre>
<p>Or, I can use the for loop function and do this</p>
<pre class="brush: plain; title: ; notranslate"> for i in {blog,pr,tracker}.gogoair.com; do echo &quot;$i&quot; ; dig +short &quot;$i&quot;; done </pre>
<p>Got to love technology <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .. Makes you lazy!!..err I meant to say productive.</p>
<p>Thx to Cliff for the inspiration.</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2011/06/23/how-to-for-loop-in-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HOW TO : Combining Perl and Zoho to produce reports</title>
		<link>http://kudithipudi.org/2011/01/26/how-to-combining-perl-and-zoho-to-produce-reports/</link>
		<comments>http://kudithipudi.org/2011/01/26/how-to-combining-perl-and-zoho-to-produce-reports/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 04:00:27 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=888</guid>
		<description><![CDATA[This HOW TO is more for my notes. We had a request at work, where we had to parse some log files and create a graph from the data in the log files. The log files looked like this I wrote the following perl script to get the log file to look as such perl [...]]]></description>
			<content:encoded><![CDATA[<p>This HOW TO is more for my notes. We had a request at work, where we had to parse some log files and create a graph from the data in the log files.</p>
<p>The log files looked like this</p>
<pre class="brush: bash; title: ; notranslate">
0m0.107s
0m0.022s
0m0.015s
2011-01-05_02_22
0m0.102s
0m0.024s
0m0.014s
2011-01-05_02_23
</pre>
<p>I wrote the following perl script to get the log file to look as such</p>
<pre class="brush: bash; title: ; notranslate">| 0m0.107s| 0m0.022s| 0m0.015s| 2011-01-05 | 02:22

| 0m0.102s| 0m0.024s| 0m0.014s| 2011-01-05 | 02:23 </pre>
<p>perl script</p>
<pre class="brush: perl; title: ; notranslate">
#!/usr/bin/perl
# Modules to load
# use strict;
use warnings;

# Variables
my $inputFile = 'input.txt';
my $version = 0.1;

my $logFile = 'parsed_input.csv';

# Sub Functions
sub Log($$$);
sub Trim($);

# Clear the screen
system $^O eq 'MSWin32' ? 'cls' : 'clear';

# Open the output log file
open(LOGFILE,&quot;&gt; $logFile&quot;) || die &quot;Couldn't open $logFile, exiting $!\n&quot;;

# Open the input file
open(INPUTFILE,&quot;&lt; $inputFile&quot;) || die &quot;Couldn't open $inputFile, exiting $!\n&quot;;

# Process the input file, one line at a time
while (defined ($line = &lt;INPUTFILE&gt;)) {
	chomp $line;
	# Check for blank line
	if ($line =~ /^$/)
		{
			# Start a new line in the output
			print LOGFILE &quot;\n&quot;;
		}
	else
		{
			# Split the date and time
			if ($line =~ /2011/)
				{
					@date = split (/_/,$line);
					print LOGFILE &quot;| $date[0] | $date[1]:$date[2]&quot;;
				}
			else
				{
					# Write the value to the output
					print LOGFILE &quot;| $line&quot;;
				}
		}
	}
</pre>
<pre><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">I then took the parsed log files and imported them into the cloud based reporting engine provided by Zoho at <a href="http://reports.zoho.com">http://reports.zoho.com</a></span></pre>
<p>The final result are these reports</p>
<p><a href="http://reports.zoho.com/ZDBDataSheetView.cc?OBJID=144766000000038450&amp;STANDALONE=true&amp;ZDB_THEME_NAME=blue&amp;REMTOOLBAR=false&amp;INCLUDETITLE=true&amp;INCLUDEDESC=true">SERVER1</a></p>
<p><a href="http://reports.zoho.com/ZDBDataSheetView.cc?OBJID=144766000000038487&amp;STANDALONE=true&amp;ZDB_THEME_NAME=blue&amp;REMTOOLBAR=false&amp;INCLUDETITLE=true&amp;INCLUDEDESC=true">SERVER2</a></p>
<p>Did I say, I love technology? <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2011/01/26/how-to-combining-perl-and-zoho-to-produce-reports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO : Improve Jboss startup times</title>
		<link>http://kudithipudi.org/2009/12/31/how-to-improve-jboss-startup-times/</link>
		<comments>http://kudithipudi.org/2009/12/31/how-to-improve-jboss-startup-times/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 22:11:41 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=749</guid>
		<description><![CDATA[We run multiple applications in Jboss at my work and one of the applications used to take an inordinate time to come up. A typical application would take &#60; 1 minute to get deployed and this particular application for some reason was taking ~7-8 minutes. We initially thought it was a bug in the code [...]]]></description>
			<content:encoded><![CDATA[<p>We run multiple applications in Jboss at my work and one of the applications used to take an inordinate time to come up. A typical application would take &lt; 1 minute to get deployed and this particular application for some reason was taking ~7-8 minutes. We initially thought it was a bug in the code and gave hell to our development team <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .. But on closer investigation, we found out that a feature we enabled in the Jboss server settings which allows content to be hosted on network storage was causing the issue.</p>
<p>I blogged the feature in Jboss to follow sym links here (<a href="http://kudithipudi.org/2008/07/25/howto-configure-jboss-to-follow-symbolic-links/">http://kudithipudi.org/2008/07/25/howto-configure-jboss-to-follow-symbolic-links/</a>). So essentially when Jboss was started, it was checking all the content in these network path to check for applications to deploy. And traversing a network share with 1000s of directories isn&#8217;t fun <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ..</p>
<p>We fixed it by making a simple edit to the start up script. Here&#8217;s the psuedo code for the script</p>
<ol>
<li>Remove soft links to network share</li>
<li>Start Jboss</li>
<li>Put soft links to network share</li>
</ol>
<p>And now the application starts in less than a minute <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I guess there might be other elegant ways to do this. i.e. Configure Jboss to only deploy certain applications, but this did the trick for us <img src='http://kudithipudi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2009/12/31/how-to-improve-jboss-startup-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO : Perl subfunction to unmount a partition in Linux</title>
		<link>http://kudithipudi.org/2009/05/22/how-to-perl-subfunction-to-unmount-a-partition-in-linux/</link>
		<comments>http://kudithipudi.org/2009/05/22/how-to-perl-subfunction-to-unmount-a-partition-in-linux/#comments</comments>
		<pubDate>Sat, 23 May 2009 02:18:23 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=615</guid>
		<description><![CDATA[For my record&#8230;here&#8217;s a snippet of perl code that can be called as a sub function to unmount a partition in Linux. Â The magic is in the line &#8220;grep m{$mountPoint}, qx{/bin/mount}&#8221;, which essentially lets you check if the partition is already mounted or not. sub UnMountVolume($) { my $mountPoint = $_[0]; print "Unmounting $mountPoint\n"; # [...]]]></description>
			<content:encoded><![CDATA[<p>For my record&#8230;here&#8217;s a snippet of <a href="http://perl.org">perl</a> code that can be called as a sub function to unmount a partition in Linux. Â The magic is in the line &#8220;grep m{$mountPoint}, qx{/bin/mount}&#8221;, which essentially lets you check if the partition is already mounted or not.</p>
<pre><code>sub UnMountVolume($)
{
    my $mountPoint = $_[0];

    print "Unmounting $mountPoint\n";
	# Check if the mount point exists
	if ( grep m{$mountPoint}, qx{/bin/mount} )
	{
		#Let's try to unmount it
		system("/bin/umount $mountPoint");
	}
	else
	{
		print "$mountPoint is not mounted, so didn't have to do anything\n";
	}
}
</code></pre>
<p>As with any perl code, I am sure there are a tons of ways to do this in a more efficient and &#8220;cool&#8221; way.</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2009/05/22/how-to-perl-subfunction-to-unmount-a-partition-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO : Find which interface a particular IP address is configured on</title>
		<link>http://kudithipudi.org/2009/05/22/how-to-find-which-interface-a-particular-ip-address-is-configured-on/</link>
		<comments>http://kudithipudi.org/2009/05/22/how-to-find-which-interface-a-particular-ip-address-is-configured-on/#comments</comments>
		<pubDate>Fri, 22 May 2009 19:28:53 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kudithipudi.org/?p=611</guid>
		<description><![CDATA[There are a ton of scripts to find how many IP addresses Â are configured on a system, but I could not find one, whic would show me which particular network interface an IP address was configured on. Here is a one liner, that will give you this information in Linux /sbin/ifconfig &#124; grep -B1 10.10.10.10 [...]]]></description>
			<content:encoded><![CDATA[<p>There are a ton of scripts to find how many IP addresses Â are configured on a system, but I could not find one, whic would show me which particular network interface an IP address was configured on. Here is a one liner, that will give you this information in <a href="http://en.wikipedia.org/wiki/Linux">Linux</a></p>
<p><code> /sbin/ifconfig | grep -B1 10.10.10.10 | awk '{if (NR==1) print $1}'</code></p>
<p>The same script can be changes a bit to support other operating systems too. Essentially, I am doing a grep (search) of the output of ifconfig, which shows all the network information on the system for a particular IP. At the same time, I am using the -B1 option, which will show the line above the matching line. Finally, I am piping this to awk and printing the first row in the first column.</p>
]]></content:encoded>
			<wfw:commentRss>http://kudithipudi.org/2009/05/22/how-to-find-which-interface-a-particular-ip-address-is-configured-on/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

