ywho -- A better rwho
James Pierre Lewis
james at yunexus.UUCP
Fri Nov 4 06:25:48 AEST 1988
#! /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
# ywho.1v
# ywho.c
# This archive created: Thu Nov 3 15:22:31 1988
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(1815 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
XCFLAGS = -O
X
XDEST = /usr/local/bin
X
XEXTHDRS = /usr/include/netdb.h \
X /usr/include/netinet/in.h \
X /usr/include/rpc/auth.h \
X /usr/include/rpc/auth_unix.h \
X /usr/include/rpc/clnt.h \
X /usr/include/rpc/rpc.h \
X /usr/include/rpc/rpc_msg.h \
X /usr/include/rpc/svc.h \
X /usr/include/rpc/svc_auth.h \
X /usr/include/rpc/types.h \
X /usr/include/rpc/xdr.h \
X /usr/include/rpcsvc/rusers.h \
X /usr/include/stdio.h \
X /usr/include/sys/socket.h \
X /usr/include/sys/sysmacros.h \
X /usr/include/sys/time.h \
X /usr/include/sys/types.h \
X /usr/include/time.h \
X /usr/include/utmp.h
X
XHDRS =
X
XLDFLAGS =
X
XLIBS =
X
XLINKER = cc
X
XMAKEFILE = Makefile
X
XOBJS = ywho.o
X
XPRINT = pr
X
XPROGRAM = ywho
X
XSRCS = ywho.c
X
Xall: $(PROGRAM)
X
X$(PROGRAM): $(OBJS) $(LIBS)
X $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM) -lrpcsvc
X
Xclean:; rm -f $(OBJS)
X
Xdepend:; mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
X
Xindex:; ctags -wx $(HDRS) $(SRCS)
X
Xinstall: $(PROGRAM)
X install -s $(PROGRAM) $(DEST)
X
Xprint:; $(PRINT) $(HDRS) $(SRCS)
X
Xprogram: $(PROGRAM)
X
Xtags: $(HDRS) $(SRCS); ctags $(HDRS) $(SRCS)
X
Xupdate: $(DEST)/$(PROGRAM)
X
X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
X @make -f $(MAKEFILE) DEST=$(DEST) install
X###
Xywho.o: /usr/include/stdio.h /usr/include/utmp.h /usr/include/rpc/rpc.h \
X /usr/include/rpc/types.h /usr/include/sys/types.h \
X /usr/include/sys/sysmacros.h /usr/include/netinet/in.h \
X /usr/include/rpc/xdr.h /usr/include/rpc/auth.h \
X /usr/include/rpc/clnt.h /usr/include/rpc/rpc_msg.h \
X /usr/include/rpc/auth_unix.h /usr/include/rpc/svc.h \
X /usr/include/rpc/svc_auth.h /usr/include/rpcsvc/rusers.h \
X /usr/include/sys/socket.h /usr/include/sys/time.h /usr/include/time.h \
X /usr/include/netdb.h
SHAR_EOF
if test 1815 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 1815 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'ywho.1v'" '(828 characters)'
if test -f 'ywho.1v'
then
echo shar: will not over-write existing file "'ywho.1v'"
else
sed 's/^ X//' << \SHAR_EOF > 'ywho.1v'
X.TH YWHO 1V "2 November 1988"
X.SH NAME
Xywho \- who on all clients in a Sun network.
X.SH SYNOPSIS
X.B ywho
X[ host ]
X.SH DESCRIPTION
X.I ywho
Xis another version of rwho, but it is faster than rwho and requires
Xno /usr/spool/rwho/rwhod.*. Note that rwho wastes system resources, but
Xywho doesn't. It utilizes SUN RPC and XDR protocol.
X.nf
X
XUser tty login idle host
Xoperator console Oct 26 06:28 00:03:48 (yetti)
Xjames tty06 Nov 3 11:09 (yetti)
Xjxu tty0a Nov 3 10:00 00:05:00 (mithra)
Xjonathan tty0b Nov 3 09:57 00:00:39 (bigfoot)
Xli tty0c Nov 3 14:32 00:00:15 (nexus)
X.fi
X.SH AUTHORS
XJames P. Lewis, York University, 1988
X.SH SEE ALSO
X/etc/hosts
X.SH NOTE
XWhen a host is down, it retries until timeout. It only works if your
Xserver and clients are configured with SUN RPC.
SHAR_EOF
if test 828 -ne "`wc -c < 'ywho.1v'`"
then
echo shar: error transmitting "'ywho.1v'" '(should have been 828 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'ywho.c'" '(2402 characters)'
if test -f 'ywho.c'
then
echo shar: will not over-write existing file "'ywho.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'ywho.c'
X#include <stdio.h>
X#include <utmp.h>
X#include <rpc/rpc.h>
X#include <rpcsvc/rusers.h>
X#include <sys/socket.h>
X#include <sys/time.h>
X#include <netdb.h>
X
X#define HST_LEN 31
X
X/*---------------------------------------------------------------------------*/
X
Xmain(argc, argv)
X
Xchar **argv;
Xint argc;
X{
X extern char *ctime();
X char hst_nam[HST_LEN],
X tmp[BUFSIZ];
X int addrlen,
X hh,
X i,
X j,
X mm,
X sock = RPC_ANYSOCK,
X ss;
X register CLIENT *client;
X struct hostent *hp;
X struct timeval pertry_timeout,
X total_timeout;
X struct utmpidlearr cutmpidlearr;
X struct sockaddr_in server_addr;
X enum clnt_stat clnt_stat;
X
X
X if (argc < 2)
X gethostname(hst_nam, HST_LEN);
X else strcpy(hst_nam, argv[1]);
X
X if ((hp = gethostbyname(hst_nam)) == NULL)
X {
X fprintf(stderr, "can't get addr for %s\n", hst_nam);
X exit();
X }
X
X pertry_timeout.tv_sec = 3;
X pertry_timeout.tv_usec = 0;
X addrlen = sizeof(struct sockaddr_in);
X bcopy(hp->h_addr, (caddr_t) &server_addr.sin_addr, hp->h_length);
X server_addr.sin_family = AF_INET;
X server_addr.sin_port = 0;
X
X if ((client = clntudp_create(&server_addr, RUSERSPROG,
X RUSERSVERS_IDLE, pertry_timeout, &sock)) == NULL)
X {
X clnt_pcreateerror("clntudp_create");
X exit();
X }
X
X total_timeout.tv_sec = 3;
X total_timeout.tv_usec = 0;
X clnt_stat = clnt_call(client, RUSERSPROC_NAMES, xdr_void,
X 0, xdr_utmpidlearr, &cutmpidlearr, total_timeout);
X
X if (clnt_stat != RPC_SUCCESS)
X {
X clnt_perror(client, argv[0]);
X exit();
X }
X
X clnt_destroy(client);
X printf("%-8.8s %-8.8s %-12.12s %-8.8s %s\n",
X "User", "tty", "login", "idle", "host");
X
X for (i = 0; i < cutmpidlearr.uia_cnt; i++)
X {
X j = cutmpidlearr.uia_arr[i]->ui_utmp.ut_time;
X
X if (cutmpidlearr.uia_arr[i]->ui_idle == NULL)
X *tmp = NULL;
X else
X {
X hh = mm = ss = NULL;
X
X if ((ss = cutmpidlearr.uia_arr[i]->ui_idle) > 60)
X {
X mm = ss / 60;
X ss = ss % 60;
X }
X
X if (mm > 60)
X {
X hh = mm / 60;
X mm = mm % 60;
X }
X
X sprintf(tmp, "%-2.2d:%-2.2d:%-2.2d", hh, mm, ss);
X }
X
X printf("%-8.8s %-8.8s %-12.12s %-8.8s (%s)\n",
X cutmpidlearr.uia_arr[i]->ui_utmp.ut_name,
X cutmpidlearr.uia_arr[i]->ui_utmp.ut_line,
X ctime(&j)+4,
X tmp,
X (*cutmpidlearr.uia_arr[i]->ui_utmp.ut_host) ?
X cutmpidlearr.uia_arr[i]->ui_utmp.ut_host : hst_nam);
X }
X
X exit();
X}
X
X/*---------------------------------------------------------------------------*/
SHAR_EOF
if test 2402 -ne "`wc -c < 'ywho.c'`"
then
echo shar: error transmitting "'ywho.c'" '(should have been 2402 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list