Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling bash script from ant in (linux) and (cygwin on windows)

I have a bash script called bashScript.sh.

I need to start bashScript.sh inside an ant script on windows(cygwin) and unix/linux.

How do i do this?

I have tried this, and a few other solutions, using the environment variable but there is no env.OSTYPE. And using...

    <exec executable="/bin/bash" failonerror="true">
        <arg value="bashScript.sh"/>
    </exec>

...does not work on windows(cygwin), because cygwin fails to find \bin\bash.

Thanks, if you need more information let me know.

like image 544
prolink007 Avatar asked Sep 28 '12 17:09

prolink007


People also ask

Can same shell script file run on both Windows and Linux?

SH file is very similar to the batch file of the Windows operating system and can be run in the Linux-based operating system. It is also possible to run . SH file in Windows 10 using Windows Subsystem for Linux.


1 Answers

You can create two exec tasks with different osfamilys.

Like this:

<exec dir="." executable="C:\Path\to\cygwin\bin\bash" osfamily="windows">
    <arg value="bashScript.sh"/>
</exec>
<exec dir="." executable="/bin/bash" osfamily="unix">
     <arg value="bashScript.sh"/>
</exec>
like image 56
dogbane Avatar answered Sep 27 '22 18:09

dogbane