Xref: utzoo comp.unix.wizards:8638 comp.unix.xenix:2301 Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ll-xn!mit-eddie!uw-beaver!apollo!mrst!sdti!mjy From: mjy@sdti.UUCP (Michael J. Young) Newsgroups: comp.unix.wizards,comp.unix.xenix Subject: Re: multi/single-user mode flag? Keywords: What number? Message-ID: <268@sdti.UUCP> Date: 18 May 88 15:21:00 GMT References: <3595@psuvax1.psu.edu> <243@oha.UUCP> <340@conexch.UUCP> <166@ofc.Columbia.NCR.COM> Reply-To: mjy@sdti.UUCP (0000-Michael J. Young) Organization: Software Development Technologies, Sudbury MA Lines: 43 In article <166@ofc.Columbia.NCR.COM> rogers@ofc.UUCP (H. L. Rogers) writes: >In article <340@conexch.UUCP> root@conexch.UUCP (Larry Dighera) writes: >>The normal way for a Sys V user to determine which run level state the system >>is in, is to do a 'who -r'. >True, but since there is no 'standard' which specifies the system state for >a particular run level number, a user program (application?) risks >portability problems from vendor to vendor. Does anyone know of any >standards work to abstract the numerical run level for Un*x systems? I don't know of a standard way, but this should work for System V at least. No flames for style or accuracy. Not a shar. --------------------- cut here ---------------- cut here ------------------- # include # include # include extern struct utmp *getutid (); extern void utmpname (); int main (){ struct utmp *buf; /* will hold utmp entry */ struct utmp buf2; /* dummy entry to hold search type */ /* * look for an entry in the utmp file that is of type RUN_LVL. * The ut_line member of this entry will contain the string * "run-level %c", where %c is [sS1-6]. */ buf2.ut_type = RUN_LVL; utmpname ("/etc/utmp"); /* not really necessary */ if ((buf = getutid (&buf2)) == NULL){ perror ("rlvl: could not find RUN_LVL entry in /etc/utmp"); exit (1); } else { printf ("%c\n", buf->ut_line[10]); } exit (0); } -- Mike Young - Software Development Technologies, Inc., Sudbury MA 01776 UUCP : {decvax,harvard,linus,mit-eddie}!necntc!necis!mrst!sdti!mjy Internet : mjy%sdti.uucp@harvard.harvard.edu Tel: +1 617 443 5779 "Bill & Opus in '88" -- Consider the alternatives!