1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 16. Hostname</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch15.html" title="Chapter 15. Math"><link rel="next" href="bk03ch17.html" title="Chapter 17. HTTP Post"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 16. Hostname</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch15.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch17.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="hostname"></a>Chapter 16. Hostname</h2></div></div></div>
|
---|
2 | <STYLE TYPE="text/css"> <!-- @import url(./style.css); --> </STYLE>
|
---|
3 | <p>
|
---|
4 | This task shows the hostname or IP address of the local machine.
|
---|
5 | </p><p>
|
---|
6 | To use this task in your build files, include a task definition like this:
|
---|
7 | </p><pre class="programlisting">
|
---|
8 |
|
---|
9 | <taskdef name="hostname" classname="ise.antelope.tasks.HostnameTask"/>
|
---|
10 |
|
---|
11 | </pre><p>
|
---|
12 | </p><p>
|
---|
13 | </p><div class="table"><a name="id2523641"></a><p class="title"><b>Table 16.1. Hostname Task Attributes</b></p><table summary="Hostname Task Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>property</td><td>Name of the property to store the hostname or IP</td><td>hostname</td><td>No</td></tr><tr><td>showip</td><td>If true, get the IP address of the local machine.</td><td>false</td><td>No</td></tr><tr><td>nic</td><td>The specific name of an interface to get the hostname or IP address of.</td><td>None</td><td>No</td></tr><tr><td>showall</td><td>Get all names or IP addresses for all network interfaces on the local machine.</td><td>false</td><td>No</td></tr><tr><td>failonerror</td><td>Should the build fail if this task fails?</td><td>false</td><td>No</td></tr></tbody></table></div><p>
|
---|
14 | </p><p>
|
---|
15 | Examples:
|
---|
16 | </p><p>
|
---|
17 | </p><pre class="programlisting">
|
---|
18 |
|
---|
19 | <description>
|
---|
20 | Unit tests for hostname task, not really good as hostname is machine
|
---|
21 | dependent, so writing a portable test is hard.
|
---|
22 | </description>
|
---|
23 |
|
---|
24 | <target name="test1">
|
---|
25 | <a:unset name="hostname"/>
|
---|
26 | <a:hostname/>
|
---|
27 | <echo>hostname: ${hostname}</echo>
|
---|
28 | <a:assert name="hostname" exists="true" message="test 1 failed."/>
|
---|
29 | </target>
|
---|
30 |
|
---|
31 | <target name="test2">
|
---|
32 | <a:unset name="localhost"/>
|
---|
33 | <a:hostname property="localhost"/>
|
---|
34 | <echo>localhost: ${localhost}</echo>
|
---|
35 | <a:assert name="localhost" exists="true" message="test 2 failed."/>
|
---|
36 | </target>
|
---|
37 |
|
---|
38 | <target name="test3">
|
---|
39 | <a:unset name="localhost"/>
|
---|
40 | <a:hostname property="localhost" showall="yes"/>
|
---|
41 | <echo>all interfaces: ${localhost}</echo>
|
---|
42 | <a:assert name="localhost" exists="true" message="test 3 failed."/>
|
---|
43 | </target>
|
---|
44 |
|
---|
45 | <target name="test4">
|
---|
46 | <a:unset name="localhost"/>
|
---|
47 | <a:hostname property="localhost" showall="yes" showip="yes"/>
|
---|
48 | <echo>all interfaces by IP: ${localhost}</echo>
|
---|
49 | <a:assert name="localhost" exists="true" message="test 4 failed."/>
|
---|
50 | </target>
|
---|
51 |
|
---|
52 | <target name="test5">
|
---|
53 | <a:unset name="localhost"/>
|
---|
54 | <a:hostname property="localhost" nic="lo" showip="yes"/>
|
---|
55 | <echo>nic lo: ${localhost}</echo>
|
---|
56 | <a:assert name="localhost" value="lo:127.0.0.1" message="test 5 failed."/>
|
---|
57 | </target>
|
---|
58 |
|
---|
59 | Output:
|
---|
60 |
|
---|
61 | test1:
|
---|
62 | [echo] hostname: blackdog
|
---|
63 |
|
---|
64 | test2:
|
---|
65 | [echo] localhost: blackdog
|
---|
66 |
|
---|
67 | test3:
|
---|
68 | [echo] all interfaces: lo:127.0.0.1, eth0:, eth1:blackdog.somewhere.com, eth2:blackdog.wireless.somewhere.com
|
---|
69 |
|
---|
70 | test4:
|
---|
71 | [echo] all interfaces by IP: lo:127.0.0.1, eth0:, eth1:192.168.1.3, eth2:192.168.44.12
|
---|
72 |
|
---|
73 | test5:
|
---|
74 | [echo] nic lo: lo:127.0.0.1
|
---|
75 |
|
---|
76 | </pre><p>
|
---|
77 | </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch15.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch17.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 15. Math </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 17. HTTP Post</td></tr></table></div></body></html>
|
---|