>What i was hoping by posting the code was to find another routine to do the same job that might be easier to debug. (i know... "suck it up and deal")
Michael,
I can't think of anyway around it. You need to find out what the values of those variable are when the command craps out.
Probably not any faster but, you could try writing the values out to a log file each time the command is run. Then you could review the log file to find out what is going wrong. However, the problem may not be related to the value of the vars and this technique wouldn't give you much else.