Doing lots of repititive tasks at your workplace?

If you're a software developer or tester, esp. in Java domain, you might be doing a lot of repetitive stuff, making things boring! Consider my scenario, where we have a huge J2EE Enterprise application (source code ~600MB), where we have to get code update from SVN repository, build, deploy into weblogic server, start the server, run unit tests, create data on test DB for integration tests, run integration tests, cleanup test data, generate reports of tests, backing up files which are changed from current revision of source control (SVN), committing the files etc etc. If you use something like Ant properly, then chances are that a sizable chunk of these jobs would be just ant targets, but not all. Its like: I don't want to keep waiting for the build to finish before I start Weblogic manually. Or why cant the IE start automatically with its homepage after the server has started? Why cant it all happen automatically?

Yes..lots of things can be automated. If you know any scripting language, like BASH, PERL etc, and you want to automate these things, life would be so much easier! Chances are that most developers use windows. In that case, Cygwin is good enough for automating things! Windows command shell and its scripting feels much lower on feature set and not so well documented. I prefer Unix Bash Scripting, may be because I'm comfortable with it :)

For instance, if you want to take a backup of the files changed, then with some changes, you can use backupchanged.sh This assumes that you have a folder named backups a directory above your current working directory. This first calls SVN status, converts the backslash of windows to forward slash of Unix, creates a directory inside ../backups/ based on timestamp, iterates over all the files and copies each of them to this directory!
Some other scripts which you may find useful are: status.sh which does svn status and writes the output to a file, whose name is generated by timestamp; update.sh which does svn update and redirects the output to a file named as per timestamp.
Also, You can also use aliases very well. I use them a lot.
Here are some of my aliases:


alias build='stopweblogic; ant dist.exploded; startweblogic'
alias cleanbuild='ant clean dist.exploded'
alias dist='ant dist.exploded'
alias iexplore='/cygdrive/c/Program\ Files/Internet\ Explorer/iexplore.exe'
alias np='/cygdrive/c/Program\ Files/Notepad++/notepad++.exe'
alias runinttestall='testdbup; ant integrationTestAll; ant integrationTest.report; testdbdown'
alias rununittestall='ant unitTestAll; ant unitTest.report'
alias schemaupdate='cd database/updates ; sqlplus kundan/@ @schema_update ; cd ../../'
alias sqlkundan='sqlplus kundan/@'
alias sqlsystem='sqlplus system/@'
alias startweblogic="cmd /C 'start E:\bea\user_projects\domains\rr-domain\startWebLogic.cmd'"
alias status='./status.sh'
alias stopweblogic="cmd /C 'E:\bea\user_projects\domains\rr-domain\stopWebLogic.cmd'"
alias testdbdown='ant testdb.cleanup'
alias testdbup='ant testdb.setup'
alias update='./update.sh'


So, if I need to stop my weblogic server, build the code and start it again, then all I do is just type: build on the cygwin prompt! If I need to do schema-update, which is done by logging into sqlplus as a particular user and running an sql script by first changing into a particular directory, all I do is run: schemaupdate. Also notice how we can run windows batch files or command scripts from Cygwin using cmd /C

I hope this makes sense at least to some folks who have not realized the power of Unix! How they can automate seemingly dumb and repetitive tasks which takes the joy away from their work, and spend the remaining time in... ?? Surely not on computer (pass this reward to your body: mainly eyes!) ! May be taking breaks, going out for a walk, chatting with people (sorry.. no IM.. face to face!)

Comments

Popular posts from this blog

iOS vs Android first hand differences

Connecting to your office PC remotely via VPN? You need not keep it ON all the time! Save Power!