CW Tools originated from my desire to have a familiar Unix/Linux command-line working environment on my Windows PC. The goal was to have an environment that I could download to any PC, quickly and unattended. Having previously done a fair amount of Unix & Linux scripting, I knew this environment could also house my own shell script functions, scripts and other tools. Plus it could also be a handy way to keep together all the various 3rd party utilities that I commonly use every day, including Process Explorer, Process Monitor, Luke, mfcmapi, etc. Inspired by the book "The Productive Programmer", I wanted to find ways to work faster, and with CW Tools I wanted to prevent myself from having to repeatedly set up the same working environment on each test VM that I would create and then later tear-down.
To provide some order and structure to this environment, I developed a simple shell script framework that allows me to group my tools into directories, with each directory containing a "load_tool.sh" file that exposes each contained tool via a shell script function wrapper. By following a naming convention for these wrapper functions, the framework can provide each function with its own help (-h) option, plus the framework can also generate an on-the-fly listing of all the functions in the environment, when the user runs the "funcs" command.
Short CW Tools usage demonstration
The recommended, and simplest, installation method is to execute the file cwtools.bat from a directory on the target PC. This is commonly the user's home directory in Windows. The cwtools.bat script contains an embedded jar file cwtools.jar, which gets automatically launched, so you will need to have Java installed on the target PC. The cwtools.bat script downloads a base Cygwin environment and then install the cwtools files on top. A shortcut is also created on the desktop.
- Installation should work without any arguments like this:
cwtools.bat
(You will find the file here:tools/scripts/CWTools_Java/cwtools.bat
) - Here's an example of calling the scipt with logging enabled:
cwtools.bat -Dlog4j.logger.com.jeremy.tools=DEBUG
- Here's an example of overriding a property value defined in the internal cwtools.properties file:
cwtools.bat -Dcwtools.processshortcuts=false
- If there is a problem running cwtools.bat, you can invoke cwtools.jar directly like this:
java -jar cwtools.jar
(You will find the file here:tools/scripts/CWTools_Java/cwtools.jar
)
- Backup the existing ~/.bash_profile, as this will be overwritten.
- Unzip CW_Tools.zip into the ~/ directory.
- Rename the extracted directory to "CW_Tools".
- Generate a new ~/.bash_profile file:
cd CW_Tools
sh ./install.sh
Note: If this errors because of the use of the "function" statement in the shell scripts, ensure that the bash shell is being used. If you are using Ubuntu then it might be using the dash shell, causing /bin/sh to point to dash. To point this to bash, run "sudo dpkg-reconfigure dash".
The original method of installing CW Tools, before there was an installer that included a base Cygwin environment, was to run download.sh from an existing Cygwin installation. The script download.sh is quite clever because it contains an embedded self-executing jar file that is actually a git client (see http://eclipse.org/jgit/download/). Because the script also includes a hard-coded url to this repo, simply running download.sh without any arguments is sufficent to download this Github repo.
- Get jgit.sh from http://eclipse.org/jgit/download/
- Make a copy of the jgit.sh file before we edit it.
- Open the jgit.sh file in vi and delete the bottom (binary jar) part of the file. Note the new size of the file (in bytes) with the binary part now removed. Saved the edited jgit.sh file as jgit.sh.text
- Extract the binary part from the original jgit.sh file as follows:
dd bs=1 skip=3141 if=jgit.sh of=jgit.sh.binary
The value for the "skip" argument is the size of the jgit.sh.text in bytes. - Add the repository path to the jgit.sh.text file as follows:
exec "$java" $java_args org.eclipse.jgit.pgm.Main clone https://github.com/ripley57/CW_Tools.git
- Create the download.sh file as follows:
cat jgit.sh.text jgit.sh.binary > download.sh