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,
This question is related to
windows
bash
command-line
sh
I use Windows 10 Bash shell aka Linux Subsystem aka Ubuntu in Windows 10 as guided here
Personally I used this batch file, but it does require CygWin installed (64-bit as shown). Just associate the file type .SH with this batchfile (ExecSH.BAT in my case) and you can double-click on the .SH and it runs.
@echo off
setlocal
if not exist "%~dpn1.sh" echo Script "%~dpn1.sh" not found & goto :eof
set _CYGBIN=C:\cygwin64\bin
if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & goto :eof
:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%
for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn1.sh"') do set _CYGSCRIPT=%%A
for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%CD%"') do set _CYGPATH=%%A
:: Throw away temporary env vars and invoke script, passing any args that were passed to us
endlocal & %_CYGBIN%\mintty.exe -e /bin/bash -l -c 'cd %_CYGPATH%; %_CYGSCRIPT% %*'
Based on this original work.
Install the GitBash
tool in the Windows OS. Set the below Path
in the environment variables of System for the Git installation.
<Program Files in C:\>\Git\bin
<Program Files in C:\>\Git\usr\bin
Type 'sh' in cmd
window to redirect into Bourne shell and run your commands in terminal.
New feature in Windows - run bash on ubuntu on windows - available in Windows 10 "Insiders" builds after the Build conference:
https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/
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
The most common way to run a .sh file is using the sh command:
C:\>sh my-script-test.sh
other good option is installing CygWin
in Windows
the home
is located in:
C:\cygwin64\home\[user]
for example i execute my my-script-test.sh
file using the bash command as:
jorgesys@INT024P ~$ bash /home/[user]/my-script-test.sh
you can use also cmder
Cmder is a software package created out of pure frustration over the absence of nice console emulators on Windows. It is based on amazing software, and spiced up with the Monokai color scheme and a custom prompt layout, looking sexy from the start
On Windows 10 Anniversary Update, it's even easier to run shell commands in/with bash on ubuntu on windows
I was trying to set my region for my x-wrt r7000 netgear router, I found the following worked for me, using bash on ubuntu on windows, you do have to enable subsystem found in windows features, and dev mode on
ssh [email protected] < /mnt/c/ccode-eu.sh
Source: Stackoverflow.com