Thread View: comp.bugs.2bsd
1 messages
1 total messages
Started by Steven M. Schultz
Mon, 25 Jan 1993 18:33
'welcome' (a login time information program) (#102)
Author: Steven M. Schultz
Date: Mon, 25 Jan 1993 18:33
Date: Mon, 25 Jan 1993 18:33
394 lines
12262 bytes
12262 bytes
Subject: 'welcome' (a login time information program) (#102)
Index: local/welcome 2.11BSD
Description:
This is a program contributed by Paul Taylor (taylor@oswego.oswego.edu)
which gives information about the system in a semi-graphical form
on VT100 compatible terminals.
Repeat-By:
N/A
Fix:
Cut where indicated, unpack the shar file, cd /usr/src/local/welcome,
type "make all; make install".
==================================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:
# /usr/src/local/welcome
# This archive created: Mon Jan 25 09:27:05 1993
export PATH; PATH=/bin:/usr/bin:$PATH
if test ! -d '/usr/src/local/welcome'
then
mkdir '/usr/src/local/welcome'
fi
cd '/usr/src/local/welcome'
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X#
X# Makefile for welcome
X#
XDESTDIR=
XBINDIR= /usr/local
XCFLAGS= -O -DPDP
XSEPFLAG= -i
XPROGRAM= welcome
XSRCS= welcome.c
XLIBS=
X
X${PROGRAM}: ${SRCS}
X ${CC} ${SEPFLAG} ${CFLAGS} -o $@ $@.c ${LIBS}
X
Xinstall: ${PROGRAM} welcome.0
X install ${PROGRAM} ${DESTDIR}/${BINDIR}
X install -c -m 444 -o bin -g bin welcome.0 ${DESTDIR}/usr/local/man/cat1
X
Xwelcome.0: welcome.1
X /usr/man/manroff welcome.1 > welcome.0
X
Xtags:
X ctags -tdw *.c
X
Xclean:
X rm -f a.out core *.o welcome.0 ${PROGRAM}
X
Xdepend:
X echo 'Welcome Compiled.'
SHAR_EOF
fi
if test -f 'README'
then
echo shar: "will not over-write existing file 'README'"
else
sed 's/^X//' << \SHAR_EOF > 'README'
XDisclaimer: I originally found this program for VAX/VMS systems in
Xthe March 1988 issue of Hardcopy magazine (page 83). I do not credit
Xthe idea to me, but since the actual program was in VMS command form,
XI deided it would be nice to put it on an Ultrix compatible system.
XThis program is intended to be shareware.
X
XWelcome prints out a nice welcome message for the user.
X
XVersion 1: Initial program translated, debugged. At this time there is only
Xa set message in the middle box. Future copies should work so that it will
Xnlist the kernel and find the type of VAX and version of Ultrix.
X
XVersion 2: Added load average box and LOAD define in cpu.h
X
XVersion 3: Added CPU type and CPU define, along with Ultrix version and
Xhostname.
X
X** This program translated from VMS command language by Jim King at lsrhs
X** (And added a few extra features...)
X
XNOTES --
X
XDefine LOAD if you want the little load average box
X
XDefine CPU If you want to know the type of CPU you are using.
X
XDefine LIGHT if you want the messages in the box highlighted.
X
XDefine UVERS If you want to know the version of Ultrix.
X NOTE: This program assumes that /etc/motd is a known file
X produced by /etc/rc.
SHAR_EOF
fi
if test -f 'cpu.h'
then
echo shar: "will not over-write existing file 'cpu.h'"
else
sed 's/^X//' << \SHAR_EOF > 'cpu.h'
Xint i;
Xchar doo[100];
Xchar poo[100];
XFILE *fp;
X
X#define VAX_780 1
X#define VAX_750 2
X#define VAX_730 3
X#define VAX_8600 4
X#define VAX_8200 5
X#define VAX_8800 6
X#define MVAX_I 7
X#define MVAX_II 8
X
X/* System defines to be changed-- */
X
X#define LOAD /* If you want the load average box, keep this defined. */
X/* #define CPU /* If you want to know what type CPU you are using, keep
X this defined. NOTE: This option has only been tested for
X Ultrix V2.0, nothing else. Please... Try it and mail
X me back! */
X/* #define UVERS /* If you want to know the version of Ultrix, keep this
X defined. This will work for any system with /etc/motd.
X#define LIGHT /* If you want the stuff inside the welcome box inversed,
X keep this defined. To make it dark, just comment it out. */
X#define TTY /* If you want the tty box, keep this define */
SHAR_EOF
fi
if test -f 'welcome.1'
then
echo shar: "will not over-write existing file 'welcome.1'"
else
sed 's/^X//' << \SHAR_EOF > 'welcome.1'
X.TH welcome 1
X.SH NAME
Xwelcome \- prints out a nice welcome message with useful statistics
X.SH SYNTAX
X.B welcome
X.SH DESCRIPTION
XThe
X.PN welcome
Xcommand makes a graphic box over box and prints out the time,
Xday,
Xand system stats
X.PP
X.PN welcome
Xassumes that the file /etc/motd exists.
X.SH SEE ALSO
X/etc/motd
X.SH AUTHOR
XJim King (pulsar) Lincoln-Sudbury Regional High '88.
SHAR_EOF
fi
if test -f 'welcome.c'
then
echo shar: "will not over-write existing file 'welcome.c'"
else
sed 's/^X//' << \SHAR_EOF > 'welcome.c'
X#include <time.h>
X#include <stdio.h>
X#include "cpu.h"
X#include <nlist.h>
X
X#ifdef PDP
X#include <short_names.h>
X#endif
X
Xextern struct nlist namelist[];
Xextern struct nlist nl[];
X
Xstruct nlist nl[] = { { "_cpu" }, { "" } };
Xdouble ldvec[4];
Xint kmem;
X
Xstruct nlist namelist[] = {
X { "_avenrun" },
X { 0 }
X};
X
Xchar *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday",
X "Thursday", "Friday", "Saturday" };
X
Xchar *mons[] = { "January", "February", "March", "April",
X "May", "June", "July", "August",
X "September", "October", "November", "December" };
X
Xchar *ttime[] = { "morning ", "afternoon ", "evening ", "night " };
X
Xmain()
X{
X register struct tm *det;
X int a, b, x, y, num, cpu;
X long secs;
X char bot[100], *foo, goo[50], ap;
X time(&secs);
X#ifdef LOAD
X#if defined(PDP)
X loadav(ldvec);
X#else defined(PDP)
X nlist("/vmunix", namelist);
X if (namelist[0].n_type == 1)
X puts("/vmunix no namelist\n"), exit(1);
X kmem = open("/dev/kmem", 0);
X if (kmem <= 0)
X printf("cannot open /dev/kmem\n"), exit(1);
X lseek(kmem, (long)namelist[0].n_value, 0);
X read(kmem, &ldvec[0], sizeof ldvec);
X close(kmem);
X#endif defined(PDP)
X#endif LOAD
X#ifdef CPU
X nlist("/vmunix", nl);
X if (nl[0].n_type == 1)
X puts("/vmunix no namelist\n"), exit(1);
X kmem = open("/dev/kmem", 0);
X if (kmem <= 0)
X printf("cannot open /dev/kmem\n"), exit(1);
X lseek(kmem, nl[0].n_value, 0);
X read(kmem, &cpu, sizeof(cpu));
X close(kmem);
X#endif CPU
X ap = "AP"[(det = localtime(&secs))->tm_hour >= 12];
X if (det->tm_hour > 0 && det->tm_hour < 12)
X foo = ttime[0];
X else if (det->tm_hour > 11 && det->tm_hour < 18)
X foo = ttime[1];
X else if (det->tm_hour > 17 && det->tm_hour < 24)
X foo = ttime[2];
X if ((det->tm_hour %= 12) == 0)
X det->tm_hour = 12;
X fflush(stdout);
X printf("\033[2J\033(0\033)0\033[m");
X#ifdef LOAD
X printf("\033[3;11H\033(B\033)B Load Average\033(0\033)0");
X printf("\033[4;11Hlqqqqqqqqqqqqqqqqk");
X printf("\033[5;11Hx x");
X printf("\033[6;11Hmqqqqqqqqqqqqqqwqj");
X printf("\033[5;13H%.02f %.02f %.02f", ldvec[0], ldvec[1], ldvec[2]);
X printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
X#else LOAD
X printf("\033[7;16Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
X#endif LOAD
X#ifdef TTY
X printf("\033[3;51H\033(B\033)BTTY Name\033(0\033)0");
X printf("\033[4;46Hlqqqqqqqqqqqqqqqqk");
X printf("\033[5;46Hx x");
X printf("\033[6;46Hmqwqqqqqqqqqqqqqqj");
X printf("\033[5;50H\033(B\033)B%s\033(0\033)0",ttyname(isatty(ttyslot())));
X printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqk");
X#else TTY
X printf("\033[7;16Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
X#endif TTY
X printf("\033[8;16Hx x");
X printf("\033[9;13Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
X printf("\033[10;10Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
X printf("\033[11;10Hx\033[11;63Hx\033[12;10Hx\033[12;63Hx\033[13;10Hx\033[13;63Hx");
X printf("\033[14;10Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
X printf("\033[15;13Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
X printf("\033[16;16Hx x");
X printf("\033[17;16Hmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj");
X printf("\033(B\033)B");
X#ifdef LIGHT
X printf("\033[11;13H\033[7m ");
X#endif LIGHT
X printf("\033[11;13H Good %s%s,", foo, getenv("USER"));
X gethostname(goo, sizeof(goo));
X#ifdef LIGHT
X printf("\033[12;13H\033[7m ");
X printf("\033[12;13H\033[7m You have connected to %s", goo);
X#else LIGHT
X printf("\033[12;13H You have connected to %s", goo);
X#endif
X#ifdef LIGHT
X printf("\033[13;13H\033[7m ");
X#endif LIGHT
X#ifdef CPU
X printf("\033[m");
X switch(cpu) {
X case VAX_780:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 11/780 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 11/780 running Ultrix");
X#endif LIGHT
X break;
X case VAX_750:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 11/750 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 11/750 running Ultrix");
X#endif LIGHT
X break;
X case VAX_730:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 11/730 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 11/730 running Ultrix");
X#endif LIGHT
X break;
X case VAX_8600:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 8600 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 8600 running Ultrix");
X#endif LIGHT
X break;
X case VAX_8200:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 8200 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 8200 running Ultrix");
X#endif LIGHT
X break;
X case VAX_8800:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A VAX 8800 running Ultrix");
X#else LIGHT
X printf("\033[13;13H A VAX 8800 running Ultrix");
X#endif LIGHT
X break;
X case MVAX_I:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A MicroVAX I running Ultrix");
X#else LIGHT
X printf("\033[13;13H A MicroVAX I running Ultrix");
X#endif LIGHT
X break;
X case MVAX_II:
X#ifdef LIGHT
X printf("\033[13;13H\033[7m A MicroVAX II running Ultrix");
X#else LIGHT
X printf("\033[13;13H A MicroVAX II running Ultrix");
X#endif LIGHT
X break;
X default:
X printf("\033[13;13H CPU ident error");
X break;
X }
X#else CPU
X#ifdef LIGHT
X#if defined(PDP)
X printf("\033[13;13H\033[7m A PDP-11 running 2.11BSD");
X#else defined(PDP)
X printf("\033[13;13H\033[7m A system running Ultrix");
X#endif defined(PDP)
X#else LIGHT
X#if defined(PDP)
X printf("\033[13;13H A PDP-11 running 2.11BSD");
X#else defined(PDP)
X printf("\033[13;13H A system running Ultrix");
X#endif defined(PDP)
X#endif LIGHT
X#endif CPU
X#ifdef UVERS
X fp = fopen("/etc/motd", "r");
X fscanf(fp, "%s%s", poo, doo);
X printf(" V%c.%c", doo[1], doo[3]);
X fclose(fp);
X unlink("/tmp/foo");
X#endif UVERS
X#ifdef LIGHT
X printf("\033[8;18H ");
X printf("\033[16;18H ");
X#endif LIGHT
X x = 40 - (strlen(days[det->tm_wday]) / 2);
X y = (69 - x);
X printf("\033[8;%dH%s", y, days[det->tm_wday]);
X sprintf(bot, "%s %d, 19%d %d:%02d %cM", mons[det->tm_mon],
X det->tm_mday, det->tm_year, det->tm_hour,
X det->tm_min, ap);
X a = 40 -(strlen(bot) / 2);
X b = (54 - a);
X printf("\033[m");
X#ifdef LIGHT
X printf("\033[7m");
X#endif LIGHT
X printf("\033[16;%dH%s", b, bot);
X printf("\033[23;1H");
X printf("\033[m");
X exit(0);
X}
SHAR_EOF
fi
cd ..
exit 0
# End of shell archive
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads