Normally I'd use Emacs, but since the target is down I'm using EditPlus2 which can switch hit. Also using Cygwin to emulate the real environment. Don't think I mentioned it, but both scripts run fine from the command line. Just not in the shell script.
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."