1,问题描述

这个报错说明的是:要求文件必须是美国信息互换标准代码格式的脚本

2,产生原因

We dont need to type out the whole script. If you copy the code from
Piazza into the editor, it appends non-ascii characters just before
the ‘#’ character. You can remove the few spaces that are present in
the middle of the line and it works.

上面这段话翻译过来就是,当我们把windows上编写好的代码文件(比如.pbs文件)通过WinSCP或者FileZilla传到位于美国的linux服务器上时(留学生可能会遇到),windows的系统可能会自动给一些 "空格,换行"以non-ascii 字符展示出来,这个时候如果在linux上运行带有non-ascii 字符编码风格的文件,就会出现这一问题。

3,解决方案

使用以下链接介绍的方法,确认自己的文件是否含有non-ascii 字符风格的编码
https://unix.stackexchange.com/questions/194435/check-whether-text-contains-non-ascii-characters-in-a-shell-script
如果有,选择其中一种合适的方法:

  1. 使用linux编辑器,每一行代码手动敲(不要从windows上复制到linux编辑器),这样百分百不会出错,但是如果代码行数太多,会比较耗时,而且容易出现打字错误
  2. 在vscode中编写的代码放到linux可能会出现这样的错误,qsub: script is written in DOS/Windows text format。 这种的话,就只需要设置vscode右下角的行尾顺序由CRLF改为LF,LF是unix下的行尾风格,但是LF是windows风格。
    在这里插入图片描述
  3. 正如那段引用所说,删除带"#"之前的空格和空行,这一方法适用.pbs文件
Logo

更多推荐