System V uptime

Thad P Floryan thad at cup.portal.com
Tue Oct 9 21:53:39 AEST 1990


len at netsys.NETSYS.COM (Len Rose) in <195 at netsys.NETSYS.COM> writes:

	Hi.. I used to have this source, but now it's temporarily
	unavailable.. (It went with the rest of my software and equipment)

	If someone can lend a hand and send me a copy, I'd appreciate it.
	Or, perhaps a pointer to an ftp site.

	Thanks.

Dunno what version about which he's referring, but here's one I use.

Thad Floryan [ thad at cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]

---- Cut Here and unpack ----
#!/bin/sh
# This is a shell archive (shar 3.32)
# made 10/09/1990 11:49 UTC by thad at thadlabs
# Source directory /u/thad/tmp
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    217 -rw-r--r-- README
#    612 -rw-r--r-- Makefile
#    814 -rw-r--r-- uptime.c
#
if touch 2>&1 | fgrep 'amc' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= README ==============
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
XThis is the ``uptime'' used on all my systems (3B1, CTIX, Motorola, SVR3, etc)
.
XAn assumption is made about the clock ticks being at a 60 Hz rate; if there's
Xdoubt on your system, use HZ from /usr/include/sys/param.h
SHAR_EOF
$TOUCH -am 1009044790 README &&
chmod 0644 README ||
echo "restore of README failed"
set `wc -c README`;Wc_c=$1
if test "$Wc_c" != "217"; then
	echo original size 217, current size $Wc_c
fi
# ============= Makefile ==============
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X# Makefile for uptime, tested on a 3B1 and on a SVR3 system
X#
XCC	=	gcc
X#CC	=	cc
XCFLAGS	=	-O
XLDFLAGS	=	-s
X#
X# the following for a 3B1 and shared library
X#
X#LIBS	=	/lib/crt0s.o /lib/shlib.ifile
X#
X# the following for SVR3 and shared library
X#
XLIBS	=	-lc_s
X#
XNAME	=	uptime
XOBJS	=	uptime.o
XSRCS	=	uptime.c
XDEST	=	/usr/local/bin
XFMODE	=	555
XOWNER	=	bin
XGROUP	=	bin
X
X$(NAME)	:	$(OBJS)
X		$(CC) $(CFLAGS) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS) 
X
Xclean	:
X		rm -f $(OBJS) core *~
X
Xinstall	:	$(NAME)
X		mv    $(NAME)  $(DEST)/
X		chown $(OWNER) $(DEST)/$(NAME)
X		chgrp $(GROUP) $(DEST)/$(NAME)
X		chmod $(FMODE) $(DEST)/$(NAME)
SHAR_EOF
$TOUCH -am 1009044790 Makefile &&
chmod 0644 Makefile ||
echo "restore of Makefile failed"
set `wc -c Makefile`;Wc_c=$1
if test "$Wc_c" != "612"; then
	echo original size 612, current size $Wc_c
fi
# ============= uptime.c ==============
echo "x - extracting uptime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > uptime.c &&
X/*	uptime.c
X *
X *	displays system uptime and boot-time
X *
X *	3-August-1990, Thad Floryan, original release
X *	23-August-1990, Thad Floryan, "fixed" the output format to be conducive
X *			for use with shell scripts
X */
X
X#include <sys/types.h>
X#include <sys/times.h>
X
Xmain()
X{
X	extern long time(), times();
X	extern char *ctime();
X
X	long boottime, uptime;
X	long days, hours, minutes, secs;
X	struct tms timebuf;
X
X	uptime   = times(&timebuf)/60L;
X	boottime = time((long *) 0) - uptime;
X	days     = uptime / (24L*60L*60L);
X	secs     = uptime % (24L*60L*60L);
X	hours    = ( secs / (60L*60L)       );
X	minutes  = ((secs % (60L*60L)) / 60L);
X	secs     = ((secs % (60L*60L)) % 60L);
X
X	printf("up %ld day%s %ld:%02ld:%02ld   booted %s",
X		days,
X		((days == 1L) ? "" : "s"),
X		hours,
X		minutes,
X		secs,
X		ctime(&boottime));
X}
SHAR_EOF
$TOUCH -am 1009044790 uptime.c &&
chmod 0644 uptime.c ||
echo "restore of uptime.c failed"
set `wc -c uptime.c`;Wc_c=$1
if test "$Wc_c" != "814"; then
	echo original size 814, current size $Wc_c
fi
exit 0



More information about the Alt.sources mailing list