Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site ihlpg.UUCP Path: utzoo!linus!decvax!bellcore!petrus!sabre!zeta!epsilon!gamma!ulysses!mhuxr!mhuxn!ihnp4!ihlpg!jchvr From: jchvr@ihlpg.UUCP (VanRietschote) Newsgroups: net.sources Subject: TTY a better version of tty Message-ID: <1539@ihlpg.UUCP> Date: Tue, 7-Jan-86 13:34:26 EST Article-I.D.: ihlpg.1539 Posted: Tue Jan 7 13:34:26 1986 Date-Received: Wed, 8-Jan-86 08:07:53 EST Distribution: net Organization: AT&T Bell Laboratories Lines: 54 --- This version of tty allows an optional argument being the login whose tty you need to know. without arguments it works like the standard tty without arguments. For more info see tty(1) or next news item with manual page. Feel free to use or abuse this program at your own risk. -- cut here --- /* tty improved version will take login name as argument -*-update-version-*- ** HFVR VERSION=Thu Dec 12 14:34:46 1985 */ #include #include #include #include main(argc,argv) int argc; char *argv[]; { struct utmp *record; extern struct utmp *getutent(); extern char *getlogin(); int user; char *name; /* checkoptions */ if ( argc >= 2 ) { if ( argv[1][0] == '-' ) { switch (argv[1][1]) { case 'V': fprintf(stderr,"%s: version 0.99\n",argv[0]); exit(1); break; default : fprintf(stderr,"Usage: %s [login]\n",argv[0]); exit(1); break; }/*switch*/ }/*fi*/ }/*fi*/ if ( argc == 2 ) { name = argv[1]; } else { name = getlogin(); } while ( (record = getutent()) != NULL ) { if ( strncmp(record->ut_user,name,8) == 0 ) { printf("/dev/%s\n",record->ut_line); exit(0); }/*fi*/ }/*while*/ exit(1); }/*main*/