README FOR lookx 5.0 -------------------- lookx uses the system's native mechanism to look up hostnames, IP addresses, usernames, UIDs, groups, GIDs, services, and port numbers. The impetus for creating this script was the lack of such a tool on Mac OS X, where the mechanism can get quite convoluted. INSTALLATION ------------ In the Makefile, set INST_ROOT to wherever you want the software installed. You may also need to change the INSTALL command, depending on the location and version of "install" on your system. Then run "make install". USE --- It's not expected that you run lookx directly. Instead, call it by one of the symlinks pointing to it: hostx, userx, groupx, or servx. Each takes a similar set of options and arguments, with the arguments interpreted according to the name by which it's called. The lookup results are printed to standard output. It's basically like the getent utility available on some platforms, but with a somewhat different output format that may be more useful for you, either in readability or parsability. It also has a convenient reverse lookup feature (described below). hostx converts between hostnames and IP addresses; the tool figures out which arguments are which. userx converts between usernames and UIDs, groupx between group names and GIDs, and servx between TCP/UDP services and port numbers. Here are some examples: % hostx www.occam.com 192.168.1.6 11.11.11.11 3.3.3.333 www.google.com www.occam.com -> 65.182.213.157 192.168.1.6 -> vamana.occam.int 11.11.11.11 -> NO HOSTNAME FOUND 3.3.3.333 -> INVALID IP ADDRESS www.google.com -> 74.125.19.104 -> 74.125.19.147 -> 74.125.19.99 -> 74.125.19.103 % userx leonvs 0 foo leonvs -> 501 0 -> root foo -> NO UID FOUND % groupx staff 0 foo staff -> 20 0 -> wheel foo -> NO GID FOUND % servx ssh 514 foo ssh -> TCP 22 -> UDP 22 514 -> TCP shell -> UDP syslog foo -> NO TCP PORT FOUND -> NO UDP PORT FOUND If you specify the "-r" switch, the result from the first lookup will be run through another lookup, so that you can compare forward and reverse lookups for the same thing to see if they match (a common technique in software implementing network-based access restrictions). This is especially useful for host lookups: % hostx -r www.occam.com 192.168.1.6 11.11.11.11 3.3.3.333 www.google.com www.occam.com -> 65.182.213.157 -> 65.182.213.157.static.sdf.hosting.com 192.168.1.6 -> vamana.occam.int -> 192.168.1.6 11.11.11.11 -> NO HOSTNAME FOUND 3.3.3.333 -> INVALID IP ADDRESS www.google.com -> 74.125.19.104 -> cf-in-f104.google.com -> 74.125.19.147 -> cf-in-f147.google.com -> 74.125.19.99 -> cf-in-f99.google.com -> 74.125.19.103 -> cf-in-f103.google.com Specifying the "-m" switch produces tab-delimited output more easily parsed by automated tools (such as "cut"), like this: % hostx -m -r www.occam.com 192.168.1.6 11.11.11.11 3.3.3.333 www.google.com www.occam.com 65.182.213.157 65.182.213.157.static.sdf.hosting.com 192.168.1.6 vamana.occam.int 192.168.1.6 11.11.11.11 NO HOSTNAME FOUND 3.3.3.333 INVALID IP ADDRESS www.google.com 74.125.19.104 cf-in-f104.google.com www.google.com 74.125.19.147 cf-in-f147.google.com www.google.com 74.125.19.99 cf-in-f99.google.com www.google.com 74.125.19.103 cf-in-f103.google.com The "-h" switch prints a short usage statement, and the "-V" switch just prints the lookx version number. PLATFORMS --------- lookx has been written for portability to most UNIX systems. It's been tested on the following platforms: - AIX - version 5.3 - *BSD - FreeBSD 4.x - Darwin/Mac OS X - versions 6.x/10.2.x through 9.x/10.5.x - Linux - Red Hat Enterprise Linux 3 & 4 - Solaris - versions 2.5.1 through 10 CHANGES ------- You're not required by the license to submit changes back to the source, but I'd appreciate portability improvements or enhancements of general applicability. You can email new versions or contextual diffs ("diff -c old_file new_file") to . Some things to keep in mind if you do this: - Formatting - I use tabs for indentation, and sometimes to align code segments for readability. Please do the same. - Please don't use NotePad or some other Windows editor to make changes. Or if you do, get rid of the DOS linefeeds before submitting changes. - Please try to follow the formatting conventions established in the existing code. - Readability - Usually, I will trade off efficiency (of running time or of development time) in favor of readability. - Insert meaningful comments where appropriate. - Portability - All shell scripts are Bourne-compatible. I won't use shell- specific constructs from bash, ksh, etc. - Don't use OS-specific features, pathnames, etc., unless they're guarded by code checking the OS version, or they're in user-settable variables toward the top of the script. CONTRIBUTORS ------------ Leon Towns-von Stauber Enjoy! Copyright (c) 2003-2008. All rights reserved. See the LICENSE file distributed with this code for restrictions on its use and further distribution. Original distribution available at .