Launch Current Version Of Script Interpreter
I have an environment where there are certain applications that require specific versions of software to work correctly. For example, there might be an application that depends upon an ancient form of Java or Ruby or ???. Yet, when I write something, I usually do not want it to use an antiquated version. Furthermore, my new version might utilize an interpreter that is not in the PATH variable.
In the Unix-like world, we can use the shebang (#!/path/to/interpreter) construct to select a specific interpreter. But if I have fifty scripts that use a specific interpreter and then I upgrade that interpreter, the hard-coded path might be wrong. For this reason, I tend to use the interpreternamedo technique. The good thing is that this same technique works with Windows.
You need to identify the specific path where your interpreter is found. For example, in Windows, C:\Program Files\Java\jre_1.6_0_1\bin\java.exe might be where your Java program is found. In that case, enter that line into a file called "javado.bat" (Windows) or enter a path such as /opt/sun/java/jre_1.6_0_1/bin/java into a file called "javado.sh" (Unix / Linux — do not forget the #!/bin/sh at the top of the file and to make it executable). Based on your operating system and shell, you have to use the proper notation to pass in commandline arguments to your eventual execution environment, such as "$1" and "$2".
Finally, when you wish to launch an action, you merely say something like javado -jar createDailyReport.jar. If you upgrade versions, a simple edit in one place makes all your scripts work again.


