Cygwin无法执行shell脚本

时间:2014-08-25 18:05:10

标签: shell windows-7 cygwin cygpath

我正在尝试在Windows 7上使用Cygwin执行.sh文件,但我收到错误cannot execute binary file

以下是我在Cygwin命令提示符窗口中编写的内容:

$ bash cygpath --unix C:\Users\\MyName\\Documents\\MyProject\\dygraphsMaster\\generate-combined.sh

这是结果:

/usr/bin/cygpath: /usr/bin/cygpath: cannot execute binary file

1 个答案:

答案 0 :(得分:1)

使用双引号(")和整个cygpath命令用反引号(`)封闭Windows路径。

我的例子:

> pwd
/cygdrive/c/TestFolder/ScriptInsideHere

> ls -al
total 1
drwx------+ 1 Administrators Domain Users  0 Aug 25 13:08 .
drwx------+ 1 Administrators Domain Users  0 Aug 25 13:13 ..
-rwx------+ 1 Administrators Domain Users 29 Aug 25 13:08 hello_world.sh

> cat hello_world.sh
#!/bin/bash
echo Hello World

运行上述内容:

> bash `cygpath --unix "C:\TestFolder\ScriptInsideHere\hello_world.sh"`
Hello World
相关问题