use a here doc
set eu and pipefail

without setting pipefail, interactive mode will continue even if qstat and
qselect don't exist on the system