Non-Working Qsub Scripts and DOS Line-Endings
The Problem
We have an apparently good (SGE) qsub script
#!/bin/sh
#$ -cwd
#$ -e job_errors
#$ -o matlab_output
#$ -q serial.q
/software/man2/matlab/bin/matlab < Test.m
which will not run the MatLab job requested, indeed, won't run at all.
The Diagnostic
In desperation try running the qsub script at the command-line
prompt> ./Test.sh
: bad interpreter: No such file or directory
prompt>
and yet /bin/sh certainly exists (it is a link to /bin/bash).
Dark experiences from over the years slowly awaken from the subconcious and suggest the possibility of "invisible" characters in the script.
Seeing Those "Invisible" Charaters (DOS Line-Endings)
Start GNU Emacs and inhibit line-ending conversion (which is automatic by default in Emacs — and in VI for that matter):
ESC-x set-variable
inhibit-eol-conversion
ihatewindowz
#
# ...set the GNU Emacs variable inhibit-eol-conversion to a non-nil
# value, in this case ihatewindowz...
#
and then open Test.sh — the "^M" characters appear at the
end of each line.