Firstly, the bash script works fine when I call it outside of ant.
Here is the relevant part of the build.xml
<exec executable="/bin/bash" failonerror="true">
<arg value="-c" />
<arg value="script.sh" />
</exec>
Here is the relevant line in the bash script (script.sh):
nc -l 8044 | tee ./nc-out.txt &
When I call script.sh from bash, the contents of nc-out.txt get populated with the data sent to port 8044.
I require the ampersand there.
When the shell script is called from ant, it seems as if nc-out.txt is created, but stays empty.
A normal redirect such as:
nc -l 8044 > nc-out.txt &
Also does not work..
Any insight would be useful!
Thanks!
When ant exec your command its standard input is by default not tied to anything, so
netcatwill exits right away when you connect to the listening process since there is nothing more to read from stdin.Since you want to run it in the background I assume that you only want to achieve a one-way logging : you can add the
-dparameter to netcat to tell him not to read from standard input:script.sh
Fully working with the following ant build file example :
build.xml