Modified to work within cygwin on windows.  Hopefully it will also work on Unix based systems