Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Identifying .login Shells Keywords: login shell cshrc Message-ID: <2037@solo9.cs.vu.nl> Date: 14 Feb 89 01:26:32 GMT References: <309@wubios.wustl.edu> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 54 #! /bin/sh # @(#)loginsh 2.0 89/02/14 Maarten Litmaath @ VU Amsterdam (maart@cs.vu.nl) # # determine if the parent is a loginshell: if it is either a child of # /etc/init (process id 1), or /usr/etc/in.rlogind or /etc/rlogind # (note: it's unsafe to assume the parent is a loginshell iff (sic) its name # starts with a `-') # note: loginsh is BSD-specific; a SysV variant should be straightforward # if invoked with any argument, loginsh will produce some diagnostics # first find out if `sps' (the fast variant of `ps') exists - if you already # know the answer, you could replace the test either by the `sps' or the `ps' # assignments # close stderr, to prevent complaints from sh if `sps' doesn't exist exec 2>&- [ "`sps N`" ] && { PPS='sps fp ' PS='sps p ' S= } || { PPS='/bin/ps l' PS='/bin/ps ' S=.. } PSED="sed -n '2s/................. *\([^ ]*\).*/\1/p'" SED="sed -n '2s/$S..................\([^ ]*\).*/\1/p'" ppid=`$PPS$$ | eval $PSED` [ $# != 0 ] && /bin/echo -n "my ppid is $ppid, of which the ppid is " ppid=`$PPS$ppid | eval $PSED` [ $ppid = 1 ] && { [ $# != 0 ] && echo "1: init" exit 0 } cmd=`$PS$ppid | eval $SED` [ $# != 0 ] && echo "$ppid: $cmd" case "$cmd" in in.rlogind|rlogind) exit 0 esac exit 1 -- "I love it |Maarten Litmaath @ VU Amsterdam: when a plan comes together." |maart@cs.vu.nl, mcvax!botter!maart