Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!husc6!seismo!mcvax!guido From: guido@mcvax.uucp (Guido van Rossum) Newsgroups: net.unix-wizards,net.unix Subject: Re: which is my login terminal Message-ID: <6995@boring.mcvax.UUCP> Date: Sun, 29-Jun-86 19:46:09 EDT Article-I.D.: boring.6995 Posted: Sun Jun 29 19:46:09 1986 Date-Received: Fri, 11-Jul-86 04:58:00 EDT References: <34@gec-rl-hrc.co.uk> <901@isis.UUCP> Reply-To: guido@boring.uucp (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 24 Keywords: sun, control terminal Xref: watmath net.unix-wizards:18763 net.unix:8553 Apparently-To: rnews@mcvax 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