Suggestions on what to use for a console

Don Libes libes at nbs-amrf.UUCP
Fri May 16 15:45:51 AEST 1986


To summarize:  There are times when it would be useful to have a
crt (for editing) on the console, and the rest of the time it would
be useful to have a printer (for information and error logging).

In case I wasn't clear before, let me restate:  It is not true that
the online files keep accurate logs of what has printed on the
console.  An excellent example is if a user halts the systems (or
the system bops out on its own like Sun's infamous "watchdog
reset").  A power outage and return could reboot the system, and
all the log would show was that the system was booted - no reason
and no record of it having been halted.

I got some real good responses.  Both Jack Jansen <mcvax!jack> and
Rich Zellich <zellich at ALMSA-1.ARPA> suggested hooking up a
Decwriter to the printer port on the VT100.  You may have to run
the VT100 at 1200 baud in order not to overflow the printer's
buffer, but it's a small price to pay.  Just turn off the printer
while editing.

As for my suggestion of a PC console, John Sellens
<watdragon!jmsellens> tells me that the VAX 8500 uses a DEC PC as
the console (and DEC explicitly suggests adding a printer to the PC).

Ken Lalonde <watmath!kwlalonde> sent me what looks to be like a
real useful program.  "/etc/fork" starts up a shell on a nearby CRT
while in single-user mode.  Unfortunately, it looks like it
requires the source to getty (4.2BSD).

Thanks for all your responses.  I hope this helps others.
Don Libes     {seismo,umcp-cs}!nbs-amrf!libes

/etc/fork is reproduced below:
#!/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
#	fork.8
#	fork.c
# This archive created: Tue May 13 15:10:47 1986
# By:	watmath!root (Ken Lalonde)
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
	echo shar: over-writing existing file "'Makefile'"
fi
cat << \SHAR_EOF > 'Makefile'
CFLAGS=-O -I/usr/src/etc/getty

fork:	fork.o	gettytab.o subr.o init.o
	cc fork.o gettytab.o subr.o init.o -o fork

gettytab.o:	/usr/src/etc/getty/gettytab.c
	cc -c $(CFLAGS) /usr/src/etc/getty/gettytab.c

subr.o:	/usr/src/etc/getty/subr.c
	cc -c $(CFLAGS) /usr/src/etc/getty/subr.c

init.o:	/usr/src/etc/getty/init.c
	cc -c $(CFLAGS) /usr/src/etc/getty/init.c

install: fork
	install fork /etc

clean:
	rm -f fork *.o
SHAR_EOF
if test -f 'fork.8'
then
	echo shar: over-writing existing file "'fork.8'"
fi
cat << \SHAR_EOF > 'fork.8'
.TH FORK 8 LOCAL
.SH NAME
fork \- create a login shell while in single-user mode
.SH SYNOPSIS
.B /etc/fork
/dev/ttyxx
.SH DESCRIPTION
.B Fork
is used to create an instance of /bin/csh on the named terminal
while in single-user mode.
The named terminal must be hardwired.
.B Fork
is typically used when editing on a hardcopy console
becomes too frustrating.
.SH FILES
/etc/ttys for the terminal speed
SHAR_EOF
if test -f 'fork.c'
then
	echo shar: over-writing existing file "'fork.c'"
fi
cat << \SHAR_EOF > 'fork.c'
/*
 * fork tty
 * Simulate some of the actions of getty and start csh
 * on the named line.  Makes sense only in single user
 * mode, and only on hardwired lines.
 */
#include <sys/ioctl.h>
#include <stdio.h>
#include <ctype.h>
#include "gettytab.h"

char tabent[512];
char tabstrs[512];
char hostname[] = "jello pudding";	/* for the loader, never used */

struct	sgttyb tmode = {
	0, 0, CERASE, CKILL, 0
};
struct	tchars tc = {
	CINTR, CQUIT, CSTART,
	CSTOP, CEOF, CBRK,
};
struct	ltchars ltc = {
	CSUSP, CDSUSP, CRPRNT,
	CFLUSH, CWERASE, CLNEXT
};

int upper, lower, allflags;

main(argc, argv)
char **argv;
{
	int fd;
	char *c, *getletter();

	if(argc != 2) {
		fprintf(stderr, "Usage: fork ttyxx\n");
		exit(1);
	}
	c = getletter(argv[1]);
	if((fd = open("/dev/tty", 2)) < 0) {
		perror("/dev/tty");
		exit(1);
	}
	if(ioctl(fd, TIOCNOTTY, 0) < 0) {
		perror("ioctl (TIOCNOTTY)");
		exit(1);
	}
	for (fd = getdtablesize(); --fd >= 0; )
		close(fd);
	if((fd = open(argv[1], 2)) != 0) {
		perror(argv[1]);	/* useless */
		exit(1);
	}
	dup(fd);
	dup(fd);
	gettable(c, tabent, tabstrs);
	if (IS)
		tmode.sg_ispeed = speed(IS);
	else if (SP)
		tmode.sg_ispeed = speed(SP);
	if (OS)
		tmode.sg_ospeed = speed(OS);
	else if (SP)
		tmode.sg_ospeed = speed(SP);
	tmode.sg_flags = setflags(2) & 0xffff;
	tmode.sg_flags &= ~LCASE;
	tmode.sg_flags |= ECHO|CRMOD;
	ioctl(0, TIOCSETP, &tmode);
	if(fork() == 0) {
		execl("/bin/csh", "-csh", 0);
		perror("/bin/csh");
		_exit(1);
	}
	exit(0);
}

	char *
getletter(s)
char *s;
{
	FILE *fd;
	char line[256];
	char *p;
	static char x[2];
	char *rindex();

	if((fd = fopen("/etc/ttys", "r")) == NULL)
		return "default";
	if (p = rindex(s, '/'))
		s = p+1;
	while(fgets(line, sizeof(line), fd) != NULL) {
		if (line[0] != '1')
			continue;
		p = line+1;
		while(isalnum(*++p))
			;
		*p = 0;
		if(strcmp(s, line+2) == 0) {
			x[0] = line[1];
			x[1] = 0;
			fclose(fd);
			return x;
		}
	}
	fclose(fd);
	return "default";
}
SHAR_EOF
#	End of shell archive
exit 0



More information about the Comp.unix.wizards mailing list