get hostname in ant easily

After searching a while, here is the best way I found to get the hostname in a propert. Just use exec task :

<exec dir="${basedir}" executable="hostname" outputproperty="host.name">

The trick is the attribute outputpropety of the exec task. You can then use ${host.name} variable to use the hostname in your ant scripts.

comments powered by Disqus