<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sample_target" name="SampleCodes">
<hostinfo prefix="host" host="localhost"/>
<target name="sample_target">
<echo message="NAME = ${host.NAME}" />
<echo message="DOMAIN = ${host.DOMAIN}" />
<echo message="IP = ${host.ADDR4}" />
<echo message="IP(v6) = ${host.ADDR6}" />
</target>
</project>
出力結果
sample_target:
[echo] NAME = localhost
[echo] DOMAIN = localdomain
[echo] IP = 127.0.0.1
[echo] IP(v6) = 0:0:0:0:0:0:0:1
BUILD SUCCESSFUL
Total time: 293 milliseconds
例2:hostにwww.yahoo.co.jpを指定
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sample_target" name="SampleCodes">
<hostinfo prefix="host" host="www.yahoo.co.jp"/>
<target name="sample_target">
<echo message="NAME = ${host.NAME}" />
<echo message="DOMAIN = ${host.DOMAIN}" />
<echo message="IP = ${host.ADDR4}" />
<echo message="IP(v6) = ${host.ADDR6}" />
</target>
</project>
出力結果
sample_target:
[echo] NAME = f7
[echo] DOMAIN = top.vip.kks.yahoo.co.jp
[echo] IP = 183.79.75.234
[echo] IP(v6) = ::
BUILD SUCCESSFUL
Total time: 4 seconds
例3:hostを指定せず
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sample_target">
<hostinfo prefix="host" host="localhost"/>
<target name="sample_target">
<echo message="NAME = ${host.NAME}" />
<echo message="DOMAIN = ${host.DOMAIN}" />
<echo message="IP = ${host.ADDR4}" />
<echo message="IP(v6) = ${host.ADDR6}" />
</target>
</project>