Thanks again Nate.

You are right that SGE is overwriting TMPDIR.  
When the job runs, TMPDIR is actually set to a job specific dir like /tmp/3579.1.default.q 

It seems that I will have to change the SGE queue settings so that TMPDIR only set the "prefix" to /scratch that I want... but this would affect all users of the queue... 

We will probably have to live with that.
Thanks for all your help!
-Tin


You might want to have a dummy tool output `set` on the cluster.  Chances are that SGE is overriding $TEMP or $TMPDIR at job runtime.  You may need to set this in ~/.sge_request or use Galaxy's environment_setup_file option.

--nate