Wednesday, January 4, 2012

Cross Platform scripting with bash.

Is this title a bit confusing?

I asked this question to many people and got the same answer as "YES"
In our day to day life when we talk about bash, we refer to Linux as it's OS.

But the main punch of this blog is to mak BASH break the boundaries of Operating System.
I agree that till now bash is not capable of doing this alone.

Now any guesses about the tool?

If you guessed "CYGWIN" then consider yourself as winner ;-)

To make it more clear for people who were not able to guess it, I can put my example here:

Background: I am a consultant and work with all sorts of projects, during my last couple of projects I was automating build & release cycle for a product that is built on four platforms (Linux32, Linux64, Windows32, Windows64), hence I was desperately looking for some cross OS/platform scripting solution.

My Thoughts
: I am a BASH guy and as any developer, my first preference was to look for a solution around what I already know, rather than straight away jumping into any new technology and learning it (it was my second option though).
If it was not bash then I was looking into ant or others to do the job.
As
"The best way to do a work, is to do it." --Harpreet Singh

For Newbies
: Cygwin is Linux-like environment for Windows making it possible to port software running on POSIX systems (such as Linux, BSD, and Unix systems) to Windows.

Solution: Now lets put this together.
Install Cygwin on a windows system with basic features like "openssh", "vim", etc.
That's it you are ready to rock 'n' roll.
All most all your Linux commands can run in this shell, which includes doing "ssh" into a Windows system ;-)

Need More: The story is not over yet. Combining the above setup with a CI tool (Jenkins in my case), gave me what I wanted.
A full fledged automated build system, running on four platforms simultaneously (using Jenkins' multi configuration project feature), with ease of writing the script only once and that too using BASH.

Now that's what I call a win ;-)

The winners prize: As a prize of my effort done for the above setup I got:
* Time saved per build/release cycle.
* Time saved in developing automation scripts.

And more important a "Happy Client"

No comments:

Post a Comment