Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a shell script through Cygwin on Windows

I have a bunch of shell scripts that used to run on a Linux machine. Now, we've switched over to Windows, and I need to run these scripts there. I have Cygwin installed, but is there a way to make the script run using Cygwin, but the call is made from Windows batch?

like image 502
rainman_s Avatar asked Apr 01 '13 02:04

rainman_s


People also ask

How do I run a .sh script in Windows?

Execute Shell Script FilesOpen Command Prompt and navigate to the folder where the script file is available. Type Bash script-filename.sh and hit the enter key. It will execute the script, and depending on the file, you should see an output.

Does Cygwin use Bash?

The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs. Using this one can even create an emulated X server on your windows box and run UNIX-like GUI software tools.


1 Answers

Sure. On my (pretty vanilla) Cygwin setup, bash is in c:\cygwin\bin so I can run a bash script (say testit.sh) from a Windows batch file using a command like:

C:\cygwin\bin\bash testit.sh 

... which can be included in a .bat file as easily as it can be typed at the command line, and with the same effect.

like image 99
Simon Avatar answered Sep 22 '22 09:09

Simon