source: release-kits/wirk3/ant-scripts/tasks/antelope/docs/manual/bk03ch16.html@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 4.8 KB
Line 
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>
4This task shows the hostname or IP address of the local machine.
5</p><p>
6To use this task in your build files, include a task definition like this:
7</p><pre class="programlisting">
8
9 &lt;taskdef name="hostname" classname="ise.antelope.tasks.HostnameTask"/&gt;
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>
15Examples:
16</p><p>
17</p><pre class="programlisting">
18
19 &lt;description&gt;
20 Unit tests for hostname task, not really good as hostname is machine
21 dependent, so writing a portable test is hard.
22 &lt;/description&gt;
23
24 &lt;target name="test1"&gt;
25 &lt;a:unset name="hostname"/&gt;
26 &lt;a:hostname/&gt;
27 &lt;echo&gt;hostname: ${hostname}&lt;/echo&gt;
28 &lt;a:assert name="hostname" exists="true" message="test 1 failed."/&gt;
29 &lt;/target&gt;
30
31 &lt;target name="test2"&gt;
32 &lt;a:unset name="localhost"/&gt;
33 &lt;a:hostname property="localhost"/&gt;
34 &lt;echo&gt;localhost: ${localhost}&lt;/echo&gt;
35 &lt;a:assert name="localhost" exists="true" message="test 2 failed."/&gt;
36 &lt;/target&gt;
37
38 &lt;target name="test3"&gt;
39 &lt;a:unset name="localhost"/&gt;
40 &lt;a:hostname property="localhost" showall="yes"/&gt;
41 &lt;echo&gt;all interfaces: ${localhost}&lt;/echo&gt;
42 &lt;a:assert name="localhost" exists="true" message="test 3 failed."/&gt;
43 &lt;/target&gt;
44
45 &lt;target name="test4"&gt;
46 &lt;a:unset name="localhost"/&gt;
47 &lt;a:hostname property="localhost" showall="yes" showip="yes"/&gt;
48 &lt;echo&gt;all interfaces by IP: ${localhost}&lt;/echo&gt;
49 &lt;a:assert name="localhost" exists="true" message="test 4 failed."/&gt;
50 &lt;/target&gt;
51
52 &lt;target name="test5"&gt;
53 &lt;a:unset name="localhost"/&gt;
54 &lt;a:hostname property="localhost" nic="lo" showip="yes"/&gt;
55 &lt;echo&gt;nic lo: ${localhost}&lt;/echo&gt;
56 &lt;a:assert name="localhost" value="lo:127.0.0.1" message="test 5 failed."/&gt;
57 &lt;/target&gt;
58
59Output:
60
61test1:
62 [echo] hostname: blackdog
63
64test2:
65 [echo] localhost: blackdog
66
67test3:
68 [echo] all interfaces: lo:127.0.0.1, eth0:, eth1:blackdog.somewhere.com, eth2:blackdog.wireless.somewhere.com
69
70test4:
71 [echo] all interfaces by IP: lo:127.0.0.1, eth0:, eth1:192.168.1.3, eth2:192.168.44.12
72
73test5:
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>
Note: See TracBrowser for help on using the repository browser.