Shell Scripts

Written by Larry Gray on . Posted in Shell Scripts

Scripts come in about two kinds for me, DOS batch files and Bash Shell Scripts on Linux and Ant scripts which are in XML format. What are scripts good for? Automation. A developer finds himself doing certain time consuming task repeatedly. This is a good sign that a script is needed. A programmer spends his life trying to turn 1,000,000,000 instructions into 1,000,000. And 1,000,000 into 100,000. And 100,000 into 1,000, and 1,000 into 100, and 100 into 10, and 10 into 1. Finally this ends up as a single mousce click. This is programming. This is scripting. I don't have much to say here so I'll refer you to the articles on Windows Shell(used to be DOS), Bash and Ant.

Java Ant

Written by Larry Gray on . Posted in Ant

Java Ant

While DOS and Unix shell scripting can automate developer task, in the Java world there is a problem with this. Both DOS and Unix shell scripts are system dependent solutions. A single developer one day decided to sit down and write Ant and it was an immediate success. Ant is a system independent solution. Ant uses XML files called build files or build.xml to describe task to be performed by Ant. Below I list some common task that ant can perform for you. To run the script you simply go to the folder with the build.xml file and run the command 'ant'. Ant will then report if it was a successful build or not.

  • compile sources
  • delete folders and files
  • move folders and files
  • archive files in jar and war files
  • build javadocs (java documentation)
  • upload files using ftp or scp to servers(for deployment)
  • run commands on the local development machine
  • run commands on remote servers
I'm sure that there is much more that ant can do for you. And you can make up custom task at will. I will update this article as I use ant and learn more.


I must at least mention Maven. Maven is another project management and building tool that works in conjunction with Ant. Maven manages the building and production of multiple projects.

Unix Bash Shell Scripts

Written by Larry Gray on . Posted in Bash

Unix Bash Shell Scripts

There are whole books written on how to code unix shells scripts. Unix shell scripts are as powerful as any programming language. I think the famous C/C++ 'make' utility is one such example. Unix usually starts up it's users with the Bash shell and I'll provide some simple examples here later. C Shell is another popular Unix alternative. Born shell is yet another.

Note that If you provide shell scripts in your distribution you will probably be providing DOS batch scripts as well. Ant is the better solution in the Java world. And uses XML for its scripting language. Ant and xml are system independent making Ant the better solution.

Windows Shell

Written by Larry Gray on . Posted in Windows Shell

Batch Scripts (MS Windows Users)

There is much on the web to teach you to code DOS batch scripts. DOS is indeed not dead. Windows 95 had its own version of DOS which has been carried into the latest versions up to Windows 7. I will provide some examples from some projects here for using DOS to automate some deployment task.

DOS can be enhanced with added commands. You may even get enhanced DOS command terminals. There used to be a color DOS which would color your terminal similar to Unix terminals. If you want to work with a unix like command terminal on windows you may use CYGWin. Though I won't talk more about CYGWin.

This kind of thing was tried in the GUI with macros but I never found that to be useful. It was difficult to setup Windows macros to work properly. And you may click on any .bat file within the windows GUI to run it. This means that you may have a .bat file or shortcut to a .bat file on your desktop or as a menu item. If you want to try out a batch file now simply make a file with .bat file extension. Put some DOS commands in it and then type its name at the command line. Stand back and watch as multiple commands run.

You may also get some support for DOS on IRC networks in #DOS channel. There were different versions of DOS at one time. PC DOS(IBM) and Dr. DOS. Today you will probably only work with MS Windows XP shell. This is the version of DOS used from XP up to Win10

If you are familiar with DOS and you want to use DOS instead of Ant then I say go for it. I mean if its quick and easy and will save you some time, then its not wrong. Though Ant is the standard for this type of thing because Ant is (made using Java) and uses XML for the scripting. Which means it is system independent. This goes well with Java since it is also system independent. If you are not familiar with DOS I recommend you read my article on Ant and install and use that instead. If you are familiar with DOS you should convert to Ant as soon as you can.