get-host() Function (SLAX)
Namespaces
http://xml.libslax.org/slax
SLAX Syntax
var $result = slax:get-host(address);
Description
Return information about the given DNS hostname, IPv4 address, or IPv6 address.
When you execute the get-host() function, the system queries the DNS
server, unless the result is cached locally in /etc/host.
Parameters
address |
Hostname, IPv4 address, or IPv6 address for which to return information. |
Return Value
result |
Node set containing a
|
Usage Examples
The following script retrieves the host information for localhost and for the host at the given IP address.
version 1.3;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
ns slax = "http://xml.libslax.org/slax";
import "../import/junos.xsl";
match / {
var $host-info = slax:get-host("localhost");
copy-of($host-info);
var $host-info2 = slax:get-host("198.51.100.1");
copy-of($host-info2);
if $host-info2/hostname {
<target> $host-info2/hostname;
}
}
The returned host information is:
<host> <hostname>localhost.example.net</hostname> <address-family>inet</address-family> <address>127.0.0.1</address> </host> <host> <hostname>router1.example.net</hostname> <address-family>inet</address-family> <address>198.51.100.1</address> </host> <target>router1.example.net</target>
Release Information
Function introduced in SLAX version 1.3.