2

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}"/>    
</exec> 
2
  • This looks correct. What isn't working? Do you get any error message? May 19, 2013 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, 2013 at 14:02

1 Answer 1

0

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/.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .