I follow your instruction, and everything looks fine....no problem.
Oh, I forgot to mention that, I call this script from a java program.
and the bash file is like a wrapper that runs other script. If I was to run the bash file against those scripts directly w/o going through java, everything works fine. But If java calls the wrapper, then wrapper executes those script; the result is 127....and sometimes is 1.