17. Why doesn't the BankTester program contain prompts for the inputs?
P RODUCTIVITY H INT 7.1: Batch Files and Shell Scripts
If you need to perform the same tasks repeatedly on the command line, then it is
worth learning about the automation features offered by your operating system.
Under Windows, you use batch files to execute a number of commands
automatically. For example, suppose you need to test a program by running three
java BankTester3 < input1.txt
Then you find a bug, fix it, and run the tests again. Now you need to type the three
commands once more. There has to be a better way. Under Windows, put the
commands in a text file and call it test.bat :
1 java BankTester1
2 java BankTester2
3 java BankTester3 < input1.txt
Then you just type
and the three commands in the batch file execute automatically.
Batch files are a feature of the operating system, not of Java. On Linux, Mac OS,
and UNIX, shell scripts are used for the same purpose. In this simple example, you
can execute the commands by typing
There are many uses for batch files and shell scripts, and it is well worth it to learn
more about advanced features such as parameters and loops.