cygwin64

Official website

https://www.cygwin.com

Linux functionality on Windows

One common use is run bash scripts on Windows

Example of a bash script

This script is meant to be run locally on a windows system with cygwin installed, it stops the tomcat service and then waits until it has exited the task list before returning.

#!/bin/bash
# Stops the tomcat service and then waits until it has exited the task list before returning
# Command line format:
# This script is meant to be run locally on a windows system with cygwin installed
# ./stopTomcatOnHost.sh

PATH=/cygdrive/c/cygwin/bin/:$PATH

# Stop the service
echo "Stopping tomcat: net stop tomcat7"
net stop tomcat7

# Wait until it leaves the tasklist
#echo $PATH
isAlive=`tasklist | grep Tomcat7.exe`
for i in {1..120}
do

	echo "Waiting for Tomcat to exit the Task List: $isAlive $i"
	
	if [ -z "$isAlive" ]; then
		break;
	fi

	sleep 1
	isAlive=`tasklist | grep Tomcat7.exe`
	
done

if [ -z "$isAlive" ]; then
	echo "Tomcat failed to stop in 120 seconds"
else	
	echo "Tomcat has been stopped"
fi