which is my login terminal
Guido van Rossum
guido at mcvax.uucp
Mon Jun 30 09:46:09 AEST 1986
In shell scripts, do the following:
case `tty` in
/dev/console) CONSOLE=YES;;
*) CONSOLE=NO;;
esac
The equivalent 'C' code is:
bool on_console() {
int i;
/* Search file descriptors 0, 1, 2 for a device name */
for (i= 0; i <= 2; ++i) {
char *p= ttyname(i);
if (p != 0 && strcmp(p, "/dev/console") == 0)
return YES;
}
return NO;
}
Of course this returns NO in a window -- there you can't 'scribble all
over the display' as the original poster asked.
Guido van Rossum, CWI, Amsterdam <guido at mcvax.uucp>
More information about the Comp.unix.wizards
mailing list