Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you execute a bash script using CygWin? I am trying execute a bash script as part of a build.xml. This is the code snippet,

<property name="cygwinpath" value="C:/cygwin/bin/"/>
<property name="script" value="D:/tomcatserverxml"/>

<exec dir="${cygwinpath}" executable="bash.exe">
    <arg value="${script}"/>    
share|improve this question
This looks correct. What isn't working? Do you get any error message? – Gilles May 19 '13 at 21:58
I get this error message : BUILD FAILED D:\build.xml:39: Execute failed: java.io.IOException: Cannot runprogram "bash.exe" (in directory "C:\cygwin\bin"): CreateProcess error=2, The system cannot find the file specified – prathi86 May 20 '13 at 14:02
up vote 0 down vote accepted

The error message say that there is no bash.exe to be found in the C:/cygwin/bin/ path.

You mention a "build.xml" so I assume that you are using Ant to do a build.

If you are using Ant from inside CygWin then you must use the CygWin conventions for paths. So you have to use simply /bin/ as path for bash.

(In this convention C:/foo/bar/ transalte to /cygdrive/c/foo/bar/ but CygWin simulate a *nix like filesistem so there is a /bin/ and a /usr/bin/ (and so on) that point to the right places. Check CygWin docs: Using Cygwin)

Do a simple check:

  • into a CygWin terminal type the command ls /bin/bash.exe : it list the executable for bash
  • open a windows CMD and type the command dir C:\cygwin\bin\bash.exe: it list the executable for bash

If the second commad fail, probably CygWin is not installed in the standard path C:/cygwin/ so do check another path like D:/cygwin/.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.