When I try to use sbatch
with my script, I get a “bad interpreter” error. Why does this occur and what can I do about it?
Bad interpreter errors when using sbatch
on Cheaha usually mean that there are symbols in the script that the shell interpreter cannot read correctly. This is usually due to the difference in newline symbols used in Windows (\r\n
) and Unix (\n
). Once these newline symbols are changed, the script should be able to run on Cheaha.
To convert a script written in Windows to be compatible on Linux, use the dos2unix
command while at a terminal on Cheaha. Just give it the name of the script to convert and it should convert it correctly.
dos2unix example_script.sh
If you are using development tools like Notepad++ or VSCode, there are built-in ways to remove the carriage returns. Using Git with GitHub and GitLab to share code between local machines and Cheaha should also “do the right thing”.
- NP++: Go to Edit >> EOL Conversion >> Unix (LF). This must be done for individual files.
- VSCode: Open Settings and search for EoL. Change the default EoL character to
\n
. This will be applied globally if changed in your User Options.