# host

DNS lookup

Syntax

    ahost [-i] [-a] (<dnsquery>[,<magicdata>]){ <callback command> }

Description

Starts a DNS lookup for the <dnsquery> and reports the results by calling the callback routine. The -i switch causes the command to execute in IpV6 mode (and lookup ONLY IpV6 hosts!).
The -a switch causes the command to run in "unspecified" mode and return any available address: IpV4 or Ipv6.
This command also performs reverse lookups (if you pass an IP address as <hostname>).
The callback command gets passed five parameters:
$0 contains the query string (<dnsquery> in fact)
$1 contains the value 1 if the query was succesfull.
In that case the remaining parameters are set as follows:
$2 contains the first ip address associated to the <dnsquery>
$3 contains the hostname associated to the <dnsquery>
$4 contains the eventual <magicdata> passed.
If $1 contains the value 0 then the query has failed and
$2 contains an error message explaining the failure.
$3 is empty
$4 contains the eventual <magicdata> passed.
Please note that if the dns query fails to even start for some reason then your callback MAY be called even before ahost() returns.

Switches

-i
Causes the command to execute in IpV6 mode (and lookup ONLY IpV6 hosts!).
-a
The -a switch causes the command to run in "unspecified" mode and return any available address: IpV4 or Ipv6.

Examples

    ahost("localhost")
    {
        echo "Lookup: "$0;
        if($1)
        {
            echo "Ip address: "$2;
            echo "Hostname: "$3;
        } else {
            echo "Error: $2";
        }
    }
    ahost -i ("irc.flashnet.it","Hello :)")
    {
        echo "Lookup: "$0;
        echo "Magic: $3";
        if($1)
        {
            echo "Ip address: "$2;
            echo "Hostname: "$3;
        } else {
            echo "Error: $2";
        }
    }
    ahost -a ("cafe:babe::dead:beef")
    {
        echo "Lookup: "$0;
        echo "Magic: $3";
        if($1)
        {
            echo "Ip address: "$2;
            echo "Hostname: "$3;
        } else {
            echo "Error: $2";
        }
    }

See also
host

Index, Commands

KVIrc 3.2.0 Documentation
Generated by root at Thu Mar 9 08:43:54 2006