如何在Windows命令提示符下运行.sh? [英] How to run .sh on Windows Command Prompt?

查看:2908
本文介绍了如何在Windows命令提示符下运行.sh?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows 7命令提示符下运行.sh?我总是在尝试运行此行时遇到此错误

  app / build / build.sh 

错误,

 无法识别'app'... 

  bash app / build / build.sh 

错误,

 无法识别bash... 
pre>

任何想法我错过了什么?



在此屏幕抓取,


解决方案

错误讯息表示您尚未安装 bash ,或不在您的 PATH 中。



顶部的Google匹配是 http://win-bash.sourceforge.net/ ,但你还需要理解大多数Bash脚本期望一个类Unix环境;所以只是安装Bash不太可能允许你运行在网络上找到的脚本,除非它是专门为这个特定的使用场景设计的。通常的解决方案是 https://www.cygwin.com/ ,但有很多可能的选择,取决于它是什么



如果Windows不是您的使用场景的核心,安装一个免费操作系统(也许是虚拟化)可能是最简单的方法。



第二个错误消息是由于Windows名义上接受正斜杠作为目录分隔符,但在此上下文中,它被解释为一个开关分隔符。换句话说,Windows将您的命令行解析为 app / build /build.sh (或者用Unix选项约定, app --build --build.sh )。您可以尝试 app\build\build.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

error,

'app' is not recognized...

or,

bash app/build/build.sh

error,

'bash' is not recognized...

Any ideas what have I missed?

Here the screen grab,

解决方案

The error message indicates that you have not installed bash, or it is not in your PATH.

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.

If Windows is not central to your usage scenario, installing a free OS (perhaps virtualized) might be the simplest way forward.

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 app\build\build.sh but it is unlikely to work, because of the circumstances outlined above.

这篇关于如何在Windows命令提示符下运行.sh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆