12.4. Using :oh To Select Printcap Information

When administering a large number of printers over a large area, it is sometimes desirable to have a default printer for each host. This default printer may be different for each host, and can be selected by using the oh entry. The oh value is a list of the following entries

    [!] IP/n     - address + mask length    10.0.0.0/8
    [!] IP/IP    - address + mask           10.0.0.0/255.0.0.0
    [!] vvv      - glob for hostname        pc*.org.com


The LPRng software will determine the hostnames and IP addresses assigned to the host and then check to see if there is a match in the listed hostnames or IP addresses. The optional test inversion (!) causes the sense of the match to be inverted. The list of addresses or entries are tested in sequence until a match is found. If no match is found the printcap entry will not be used. For example:

    lp:oh=*.admin.org.com,10.0.0.5,10.2.0.0/16:lp=pr1@server1
    lp:oh=*.eng.org.com:lp=hp@server2
    color:oh=*.eng.org.com:lp=color@server3
    color:oh=!*.eng.org.com:lp=color@server4


In the above example, if our host name is booster.admin.org.com, then we would use lp=pr1@server1, as the *.admin.org.com glob pattern would match our host name.

if our host name is booster.dev.org.com and our IP address is 10.2.0.1, then we would use lp=pr1@server1, as the 10.2.0.0/16 ip address would be in the specified address range.

Finally we have an example of the use of the match inversion operator (!). All hosts whose name matches *.eng.org.com will use color@server3 and the others will use color@server4.