问题描述
如何在 Windows 7 命令提示符下运行 .sh?当我尝试在其中运行此行时,我总是收到此错误,
How can I run .sh on Windows 7 Command Prompt? I always get this error when I try to run this line in it,
app/build/build.sh
错误,
'app' is not recognized...
或者,
bash app/build/build.sh
错误,
'bash' is not recognized...
任何想法我错过了什么?
Any ideas what have I missed?
这里是屏幕抓取,
推荐答案
该错误信息表明您尚未安装 bash
,或者它不在您的 PATH
中.
The error message indicates that you have not installed bash
, or it is not in your PATH
.
Google 最热门的是 http://win-bash.sourceforge.net/ 但您还需要了解这一点大多数 Bash 脚本需要一个类 Unix 环境;所以仅仅安装 Bash 可能不太可能让你运行你在网上找到的脚本,除非它是专门为这个特定的使用场景设计的.通常的解决方案是 https://www.cygwin.com/ 但有很多可能的替代方案,具体取决于它到底是什么你想要完成的.
The top Google hit is http://win-bash.sourceforge.net/ but you also need to understand that most Bash scripts expect a Unix-like environment; so just installing Bash is probably unlikely to allow you to run a script you found on the net, unless it was specifically designed for this particular usage scenario. The usual solution to that is https://www.cygwin.com/ but there are many possible alternatives, depending on what exactly it is that you want to accomplish.
如果 Windows 不是您使用场景的核心,安装免费操作系统(可能是虚拟化的)可能是最简单的方法.
If Windows is not central to your usage scenario, installing a free OS (perhaps virtualized) might be the simplest way forward.
第二条错误消息是由于 Windows 名义上接受正斜杠作为目录分隔符,但在这种情况下,它被解释为开关分隔符.换句话说,Windows 将您的命令行解析为 app/build/build.sh
(或者,用 Unix 选项约定来解释,app --build --build.sh
).您可以尝试 appuilduild.sh
,但由于上述情况,它不太可能奏效.
The second error message is due to the fact that Windows nominally accepts forward slash as a directory separator, but in this context, it is being interpreted as a switch separator. In other words, Windows parses your command line as app /build /build.sh
(or, to paraphrase with Unix option conventions, app --build --build.sh
). You could try appuilduild.sh
but it is unlikely to work, because of the circumstances outlined above.
这篇关于如何在 Windows 命令提示符下运行 .sh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!