开发者

How do I execute a batch file in Windows in Cygwin shell

I am trying to execute a BATCH file through through a jsp on a Windows machine and it works fine without any problems.

However DOS does not have an equivalent of sed unix command. Hence I had to install cygwin so that I can use the the following sed command in my batch file.

sed -i "s/<model.version>2.1.1-SNAPSHOT<\/model.version>/<model.version>2.1.1-b-1<\/model.version>/g" pom.xml  

My question is that how can I invoke the cygwin shell so that my .bat file runs within cygwin shell rather开发者_JS百科 than windows command prompt.

Following is the piece of code that works fine. The only problem is that it invokes command prompt. I want to invoke cygwin shell instead of command prompt.

File dir = new File("C:\\Projects\\release-builds");  
Runtime.getRuntime().exec("cmd.exe /c start build-model.bat", null, dir);  

Please advise.


You need to add the cygwin directory to your PATH. (or the PATH of your service) then you can run cygwin commands from a DOS prompt or bat script.

Or you can give the full path for your c:\cygwin\usr\bin\sed.exe or whatever it is.


Is just getting sed from gnuwin project an option? You could use it with native windows shell then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜