I'm not sure what flavour of qsub
you are using so this may not help ...
Try including
#$ -V
at the start of your script. On some systems which process qsub
it ensures that environment variables are exported from your environment to the environment in which the script eventually runs. These environments are not, generally, the same.