File: bk03ch16.html

package info (click to toggle)
antelope 3.5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 3,884 kB
  • sloc: java: 27,651; xml: 6,488; sh: 12; makefile: 5
file content (77 lines) | stat: -rw-r--r-- 5,002 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter16.Hostname</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><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="Chapter15.Math"><link rel="next" href="bk03ch17.html" title="Chapter17.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">Chapter16.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>Chapter16.Hostname</h2></div></div></div>
<STYLE TYPE="text/css"> <!-- @import url(./style.css); --> </STYLE>
    <p>
This task shows the hostname or IP address of the local machine.
</p><p>
To use this task in your build files, include a task definition like this:
</p><pre class="programlisting">

    &lt;taskdef name="hostname" classname="ise.antelope.tasks.HostnameTask"/&gt;
   
</pre><p>
</p><p>
</p><div class="table"><a name="id2552892"></a><p class="title"><b>Table16.1.Hostname Task Attributes</b></p><div class="table-contents"><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></div><p><br class="table-break">
</p><p>
Examples:
</p><p>
</p><pre class="programlisting">

   &lt;description&gt;
      Unit tests for hostname task, not really good as hostname is machine
      dependent, so writing a portable test is hard.
   &lt;/description&gt;

   &lt;target name="test1"&gt;
      &lt;a:unset name="hostname"/&gt;
      &lt;a:hostname/&gt;
      &lt;echo&gt;hostname: ${hostname}&lt;/echo&gt;
      &lt;a:assert name="hostname" exists="true" message="test 1 failed."/&gt;
   &lt;/target&gt;

   &lt;target name="test2"&gt;
      &lt;a:unset name="localhost"/&gt;
      &lt;a:hostname property="localhost"/&gt;
      &lt;echo&gt;localhost: ${localhost}&lt;/echo&gt;
      &lt;a:assert name="localhost" exists="true" message="test 2 failed."/&gt;
   &lt;/target&gt;

   &lt;target name="test3"&gt;
      &lt;a:unset name="localhost"/&gt;
      &lt;a:hostname property="localhost" showall="yes"/&gt;
      &lt;echo&gt;all interfaces: ${localhost}&lt;/echo&gt;
      &lt;a:assert name="localhost" exists="true" message="test 3 failed."/&gt;
   &lt;/target&gt;

   &lt;target name="test4"&gt;
      &lt;a:unset name="localhost"/&gt;
      &lt;a:hostname property="localhost" showall="yes" showip="yes"/&gt;
      &lt;echo&gt;all interfaces by IP: ${localhost}&lt;/echo&gt;
      &lt;a:assert name="localhost" exists="true" message="test 4 failed."/&gt;
   &lt;/target&gt;

   &lt;target name="test5"&gt;
      &lt;a:unset name="localhost"/&gt;
      &lt;a:hostname property="localhost" nic="lo" showip="yes"/&gt;
      &lt;echo&gt;nic lo: ${localhost}&lt;/echo&gt;
      &lt;a:assert name="localhost" value="lo:127.0.0.1" message="test 5 failed."/&gt;
   &lt;/target&gt;

Output:

test1:
     [echo] hostname: blackdog

test2:
     [echo] localhost: blackdog

test3:
     [echo] all interfaces: lo:127.0.0.1, eth0:, eth1:blackdog.somewhere.com, eth2:blackdog.wireless.somewhere.com

test4:
     [echo] all interfaces by IP: lo:127.0.0.1, eth0:, eth1:192.168.1.3, eth2:192.168.44.12

test5:
     [echo] nic lo: lo:127.0.0.1

</pre><p>
</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">Chapter15.Math</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">Chapter17.HTTP Post</td></tr></table></div></body></html>