hello everybody, I had similar problems, mainly fixed with the fix above. I also found a invalid PID because my PID had a ? in it. I found putting the pid in 'PID'. single quotes fixed this problem. Here is a updated and fixed script
http://paste2.org/p/640624