[comp.sys.hp] Is there a WHOIS for HP-UX?

frank@hpuxa.ircc.ohio-state.edu (Frank G. Fiamingo) (03/08/90)

Is there a "whois" program for HP9000/840?  Currently we're
running HP-UX 3.1, and will upgrade soon to 7.0.

Thanks,
Frank Fiamingo

milburn@me10.lbl.gov (John Milburn) (03/08/90)

In article <850@nisca.ircc.ohio-state.edu> frank@hpuxa.ircc.ohio-state.edu (Frank G. Fiamingo) writes:
>Is there a "whois" program for HP9000/840?  Currently we're
>running HP-UX 3.1, and will upgrade soon to 7.0.

If you mean the tcp service which does name inquiries to the NIC via
internet, here it is. It is known to work under 6.5 and 7.0.

-jem

-------------------------Cut Here----------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	whois.c
# This archive created: Wed Mar  7 20:04:13 1990
export PATH; PATH=/bin:/usr/local/bin:$PATH
echo shar: extracting "'Makefile'" '(488 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X# @(#) $Header: Makefile,v 1.4 88/03/07 02:09:50 leres Exp $ (LBL)
X#
X# Copyright (c) 1980 Regents of the University of California.
X# All rights reserved.  The Berkeley software License Agreement
X# specifies the terms and conditions for redistribution.
X#
X#	@(#)Makefile	5.17 (Berkeley) 6/7/86
X#
X#    modified for hpux 89/09/23  jem
XDESTDIR=/usr/local/bin
XCFLAGS=	-O
X
Xall: whois install
X
X
Xwhois:
X	${CC} -o whois ${CFLAGS} whois.c -lBSD
X
Xinstall:
X 	(bsdinstall -s -m 755 whois ${DESTDIR})
X
X
SHAR_EOF
if test 488 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 488 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'whois.c'" '(1908 characters)'
if test -f 'whois.c'
then
	echo shar: will not over-write existing file "'whois.c'"
else
sed 's/^X//' << \SHAR_EOF > 'whois.c'
X/*
X * Copyright (c) 1980 Regents of the University of California.
X * All rights reserved.  The Berkeley software License Agreement
X * specifies the terms and conditions for redistribution.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1980 Regents of the University of California.\n\
X All rights reserved.\n";
X#endif not lint
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)whois.c	5.3 (Berkeley) 2/8/88";
X#endif not lint
X
X#include <sys/types.h>
X#include <sys/socket.h>
X
X#include <netinet/in.h>
X
X#include <stdio.h>
X#include <netdb.h>
X
X#define	NICHOST	"nic.ddn.mil"
X
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	int s;
X	register FILE *sfi, *sfo;
X	register char c;
X	char *host = NICHOST;
X	struct sockaddr_in sin;
X	struct hostent *hp;
X	struct servent *sp;
X
X	argc--, argv++;
X	if (argc > 2 && strcmp(*argv, "-h") == 0) {
X		argv++, argc--;
X		host = *argv++;
X		argc--;
X	}
X	if (argc < 1) {
X		fprintf(stderr, "usage: whois [ -h host ] name\n");
X		exit(1);
X	}
X	hp = gethostbyname(host);
X	if (hp == NULL) {
X		fprintf(stderr, "whois: %s: host unknown\n", host);
X		exit(1);
X	}
X	host = hp->h_name;
X	s = socket(hp->h_addrtype, SOCK_STREAM, 0, 0);
X	if (s < 0) {
X		perror("whois: socket");
X		exit(2);
X	}
X	bzero((caddr_t)&sin, sizeof (sin));
X	sin.sin_family = hp->h_addrtype;
X	if (bind(s, &sin, sizeof (sin), 0) < 0) {
X		perror("whois: bind");
X		exit(3);
X	}
X	bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);
X	sp = getservbyname("whois", "tcp");
X	if (sp == NULL) {
X		fprintf(stderr, "whois: whois/tcp: unknown service\n");
X		exit(4);
X	}
X	sin.sin_port = sp->s_port;
X	if (connect(s, &sin, sizeof (sin), 0) < 0) {
X		perror("whois: connect");
X		exit(5);
X	}
X	sfi = fdopen(s, "r");
X	sfo = fdopen(s, "w");
X	if (sfi == NULL || sfo == NULL) {
X		perror("fdopen");
X		close(s);
X		exit(1);
X	}
X	while(--argc)
X		fprintf(sfo, "%s ", *argv++);
X
X	fprintf(sfo, "%s\r\n", *argv);
X	fflush(sfo);
X	while ((c = getc(sfi)) != EOF)
X		putchar(c);
X}
SHAR_EOF
if test 1908 -ne "`wc -c < 'whois.c'`"
then
	echo shar: error transmitting "'whois.c'" '(should have been 1908 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
JEMilburn@lbl.gov  ...!ucbvax!lbl.gov!JEMilburn

campbelr@hpclove.HP.COM (Bob Campbell) (03/09/90)

I am not sure what the functionality of whois is, but read the
man page for finger and see if that meets your needs.
--------------------------------------------------------------------------
Bob Campbell                Some times I wish that I could stop you from 
campbelr@hpda.hp.com        talking, when I hear the silly things you say.
Hewlett Packard                                    - Elvis Costello

milburn@me10.lbl.gov (John Milburn) (03/10/90)

In article <3770044@hpclove.HP.COM> campbelr@hpclove.HP.COM (Bob Campbell) writes:
>I am not sure what the functionality of whois is, but read the
>man page for finger and see if that meets your needs.

Whois is quite distinct from finger. Whois makes a request to the NIC,
searching the nic's database for registered users. It is sometimes quite
useful as a tool to find those responsible for major sites.

For instance:

  me10:milburn 1 %)) whois sde.hp.com
  Hewlett Packard (SDE3)
  
     Hostname: SDE.HP.COM
     Address: 15.255.152.2
     System: HP-9000/840 running HP-UX
  
     Coordinator:
        Laubach, Mark  (ML2)  laubach@HP.COM
        (408) 447-1145
  
     domain server
  
     Record last updated on 10-Nov-89.
  
     There is one registered user:
  
  Laubach, Mark (ML2)		laubach@HP.COM			(408) 447-1145
  
  To single out one record, look it up with "!xxx", where xxx is the
  handle, shown in parenthesis following the name, which comes first.
  

-jem
JEMilburn@lbl.gov  ...!ucbvax!lbl.gov!JEMilburn