运行 .bash 脚本时出现问题

运行 .bash 脚本时出现问题

我正在尝试运行以下代码:

/shared/Downloads/Chipre/processDataset_V2.bash myGraph_v3_for_GPT_v2_2.xml variables.properties "/shared/Downloads/Chipre/June" "/shared/Downloads/Chipre/GPT/June" ndvi

我发现的第一个错误是

bash: /shared/Downloads/Chipre/processDataset_V2.bash: Permission denied

我已经通过添加解决了sh

sh /shared/Downloads/Chipre/processDataset_V2.bash myGraph_v3_for_GPT_v2_2.xml variables.properties "/shared/Downloads/Chipre/June" "/shared/Downloads/Chipre/GPT/June" ndvi

现在错误声称:

: not foundnloads/Chipre/processDataset_V2.bash: 3: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 7: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 10: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 14: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 17: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 20: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 23: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 26: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 29: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 30: /shared/Downloads/Chipre/processDataset_V2.bash: 
: not foundnloads/Chipre/processDataset_V2.bash: 34: /shared/Downloads/Chipre/processDataset_V2.bash: 
/shared/Downloads/Chipre/processDataset_V2.bash: 36: /shared/Downloads/Chipre/processDataset_V2.bash: Syntax error: "(" unexpected

我已经在论坛上做了一些研究,有人说 .bash 文件必须以 sheband 行开头(在我的情况下确实如此。我的第一行是#!/bin/bash)。

我认为我的问题是我没有正确指定解释外壳,但我不知道如何解决它。

编辑 - -

如果我尝试bash并且没有sh

bash /shared/Downloads/Chipre/processDataset_V2.bash myGraph_v3_for_GPT_v2_2.xml variables.properties "/shared/Downloads/Chipre/June" "/shared/Downloads/Chipre/GPT/June" ndvi

声称的错误是:

/shared/Downloads/Chipre/processDataset_V2.bash: line 3: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 7: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 10: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 14: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 17: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 20: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 23: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 26: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 29: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 30: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 34: $'\r': command not found
/shared/Downloads/Chipre/processDataset_V2.bash: line 36: syntax error near unexpected token `$'{\r''
'shared/Downloads/Chipre/processDataset_V2.bash: line 36: `function normalizePath() {

的输出ls -l /shared/Downloads/Chipre/processDataset_V2.bash为:

-rw-r--r-- 1 rus rus 2225 Feb 28 09:00 /shared/Downloads/Chipre/processDataset_V2.bash

答案1

看起来你已经在 Windows 上写了这个,并且当你在 Windows 中创建新行时它会插入\r,但是 bash 不理解这一点。

这里看看如何删除它。

相关内容