<?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>neror.com &#187; Ruby</title>
	<atom:link href="http://www.neror.com/categories/programming/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.neror.com</link>
	<description>everyone&#039;s a critic</description>
	<lastBuildDate>Wed, 17 Feb 2010 01:31:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>I love the Unix Command Line!  And a tip of the hat to cygwin.</title>
		<link>http://www.neror.com/2005/06/08/i-love-the-unix-command-line-and-a-tip-of-the-hat-to-cygwin.html</link>
		<comments>http://www.neror.com/2005/06/08/i-love-the-unix-command-line-and-a-tip-of-the-hat-to-cygwin.html#comments</comments>
		<pubDate>Wed, 08 Jun 2005 23:07:04 +0000</pubDate>
		<dc:creator>neror</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.neror.com/?p=31</guid>
		<description><![CDATA[Quick sidenote: I haven&#8217;t figured out the RSS issue yet, but I did notice that I was getting picked up in bloglines. Hmmm. Maybe it was an old cached feed from when the feeds worked. I don&#8217;t know, and I haven&#8217;t had time to dig in and figure it out yet. This is just a [...]]]></description>
			<content:encoded><![CDATA[<blockquote>Quick sidenote: I haven&#8217;t figured out the RSS issue yet, but I did notice that I was getting picked up in bloglines.  Hmmm.  Maybe it was an old cached feed from when the feeds worked.  I don&#8217;t know, and I haven&#8217;t had time to dig in and figure it out yet.  This is just a default install of WordPress.  I haven&#8217;t even changed the damn template.  Argh!</blockquote>

<p>Anyway, I bet you&#8217;re wondering what that subject means at the top of the post.  Well, let me set the scene&#8230;</p>

<p>At work, we use some stupid Novell system to distribute our licensed apps.  One of those apps is WebSphere, which is the app server I have to test my code against.  To get WebSphere, I have to install the WebSphere Studio (basically <a href="http://www.eclipse.org">Eclipse</a> 2 with a $5,000 price tag).  Fine, I can live with that.  Now, I want to run the app server outside of WebSphere Sutdio so I can develop with Eclipse 3.0 (the free one) and deploy with ant.  Shouldn&#8217;t be too complicated, right?  Well, when WebSphere Studio is first installed, a bunch of server startup scripts and xml configuration files are generated for the app server.  Now, the supid Novell application distribution thingie mentioned earlier installs it to a different path then I am <b>forced</b> to, and all of the generated batch files have the <b><i>WRONG</i></b> hardcoded path in them.  The &#8220;good&#8221; news is it only took me about 1.5 hours to figure that out.</p>

<p>Now to the point of my post.  I had to replace their hardcoded path with mine in all of the batch files and xml files.  These files are in a myriad of directories under the main WebSphere directory.  So to make a way too long story short, I wrote a short 7 line ruby script that takes a filename as an argument on the commandline and interates over each line replacing the bad path with the good one.  That took about 5 minutes.  I know I could&#8217;ve used <a href="http://sparky.rice.edu/~hartigan/sed.html">sed</a>, but I love <a href="http://ruby-lang.org">Ruby</a>, and I like to write Ruby scripts whenever I can.  So next, I wrote a long command line to actually call the script on the appropriate files, and BAM, all done.  Grand total of about 9 minutes, 4 of which were spent refreshing myself on the <a href="http://sparky.rice.edu/~hartigan/awk.html">awk</a> syntax.  Now, how long would that have taken me if I were pointing and clicking? <img src='http://www.neror.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Anyway, I know that this isn&#8217;t anything remarkable, I just get excited when I see great tools do their job well.  The whole *nix philosophy of combining simple tools that each do their jobs very well to do complex things is so awsome.</p>

<p>Without further ado, here&#8217;s the command:</p>

<p><code> grep -re '[cC]:[/&#93;WebSphere[/&#93;AppServer' . | awk -F":" '{print $1}' | awk '{print "./replace_path.rb "$O}' | bash</code></p>

<p>And here's the trivial ruby script:</p>

<p><code>
<pre>
lines = []
File.open(ARGV[0],"r") do |file|
    file.readlines.each do |line|
        lines &lt;&lt; line.gsub(/[cC]:[\/]WebSphere[\/]AppServer/,'C:/Progra~1/IBM/WebSph~1/runtimes/aes_v4')
    end
end
File.open(ARGV[0],"w") { |file| lines.each {|x| file.puts x }}
</pre>
</code></p>

<p>Have a nice day!</p>]]></content:encoded>
			<wfw:commentRss>http://www.neror.com/2005/06/08/i-love-the-unix-command-line-and-a-tip-of-the-hat-to-cygwin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
