Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run .sh on Windows Command Prompt?

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, enter image description here

like image 371
Run Avatar asked Oct 23 '14 06:10

Run


People also ask

Can we run .sh file in Windows?

A . SH file is very similar to the batch file of the Windows operating system and can be run in the Linux-based operating system. It is also possible to run . SH file in Windows 10 using Windows Subsystem for Linux.


2 Answers

Install GIT. During installation of GIT, add GIT Bash to windows context menu by selecting its option. After installation right click in your folder select GIT Bash Here (see attached pic) and use your sh command like for example:

sh test.sh 

enter image description here

like image 157
Faisal Mq Avatar answered Sep 28 '22 10:09

Faisal Mq


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.

like image 27
tripleee Avatar answered Sep 28 '22 10:09

tripleee