#!/bin/bash : The above line tells Linux to use the shell /bin/bash to execute : this script. That must be the first line in the script. : You must have no lines beginning with # before these : PBS lines other than the /bin/bash line: #PBS -N 'COMSOLwMAT' #PBS -o 'qsub-poisson2d_matlab.log' #PBS -j oe #PBS -W umask=007 #PBS -q low_priority #PBS -l nodes=1:ppn=1 : Change our current working directory to the directory from which you ran qsub: cd $PBS_O_WORKDIR : Run COMSOL with MATLAB and pipe in the m-file: comsol matlab path -ml -nodesktop -ml -nodisplay < poisson2d_matlab.m : The -nodisplay line tells matlab not to try to use any graphics or JVM.