Windows file
Text files on Microsoft Windows and Linux (Hoffman2 cluster) use different end of line characters. While Linux uses \n
, Windows uses \n\r
. This may cause issues if the job script file is edited on a “naive” editor (such as “notepad”) on Windows and then transferred directly to Hoffman2 Cluster. A carefully configured text editor (such as VS Code) on Windows can avoid such situation.
Symptoms: a strange “bad interpreter” error message when the file appears to be ok.
Consider the file windows.sh
. The file looks normal using the cat
command:
$ cat windows.sh
#!/bin/bash
#$ -cwd
#$ -N windows
#$ -l h_rt=1:00:00,h_data=2G
But the “Windows” characters (^M
) are visible if the -v
option is added to the cat
command:
$ cat -v windows.sh
#!/bin/bash^M
^M
#$ -cwd^M
#$ -N windows^M
#$ -l h_rt=1:00:00,h_data=2G^M
^M
The problem is easily fixed by running the utility program dos2unix
on the file windows.sh
:
dos2unix windows.sh
The ^M
characters are now gone:
$ cat -v windows.sh
#!/bin/bash
#$ -cwd
#$ -N windows
#$ -l h_rt=1:00:00,h_data=2G