Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: multi/single-user mode flag? Message-ID: <7798@ncoast.UUCP> Date: 21 May 88 16:35:46 GMT References: <3595@psuvax1.psu.edu> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 28 As quoted from <3595@psuvax1.psu.edu> by okunewck@gondor.cs.psu.edu (Phil OKunewick): +--------------- | Is there any nice way for a program to tell whether a generic | unix system is in single-user or multi-user mode? Two ideas here are | to read init's memory (not standard under different unixes) or to check | what processes are running (kludge). +--------------- who > /tmp/who$$ if test -s /tmp/who$$; then echo multiuser else echo singleuser fi rm /tmp/who$$ Who doesn't produce output in singleuser mode, since it's getty that writes the login records and init spawns a shell directly in singleuser mode. This is true under all OSes I've checked (System III/V, Xenix 2/3/5, V7). It is most likely true of BSD (2.x and 4.x) as well. The gotcha: utmp formats are anything but compatible between V7/BSD and System V/Xenix 5. The easiest portable way is to have a shell script to do the dump, and have it do the "who" stuff above. -- Brandon S. Allbery, moderator of comp.sources.misc {well!hoptoad,uunet!marque,cbosgd,sun!mandrill}!ncoast!allbery Delphi: ALLBERY MCI Mail: BALLBERY