Forcing actions at login

Brandon S. Allbery KB8JRR allbery at NCoast.ORG
Mon Jan 14 10:10:48 AEST 1991


As quoted from <1991Jan10.191546.268 at am.sublink.org> by alex at am.sublink.org (Alex Martelli):
+---------------
| jc at minya.UUCP (John Chambers) writes:
| 	[discussion of using a script as shell for a pseudo-user]
| :It turns out to be a bad idea to use /bin/sh as the login shell for
| :such a script.  Why?  Well, /bin/sh insists on running /etc/profile
| :for all users; there's no (documented ;-) way to suppress this.  If 
| :your /etc/profile does "cat /etc/motd" (and most do), it is just a 
| 
| Just kludge up a way to disable motd-checking - simplest scheme I can
| think of, offhand, is to add something like:
| 	egrep "^$LOGNAME:.*NOMOTD" /etc/passwd >/dev/null && exit
+---------------

$ sed -n 6,10p /etc/profile
if test ! -f $HOME/.hushlogin; then
    if newer-than /etc/motd $HOME/.enoughalready; then
	cat /etc/motd
	touch $HOME/.enoughalready
    fi
fi
$ cat newer-than.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

main(argc, argv)
    int argc;
    char **argv;
{
    struct stat f1, f2;

    if (argc != 3)
    {
	fprintf(stderr, "usage: newer-than file1 file2\n");
	exit(2);
    }
    if (stat(argv[1], &f1) == -1)
    {
	perror(argv[1]);
	exit(2);
    }
    if (stat(argv[2], &f2) == -1)
    {
	perror(argv[2]);
	exit(2);
    }
    return (f1.st_mtime <= f2.st_mtime);
}
$ # those with "test file1 -nt file2" can use that instead
$ _

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery at NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY



More information about the Comp.unix.admin mailing list