[comp.unix.wizards] .hushlogin

MARSELLE%gmr.com@RELAY.CS.NET (05/15/87)

The other day I read someone's suggestion to use a "make -f .hushlogin"
in the .login file to only print out /etc/motd when its last mod time
changes.  Since no further advice regarding what .hushlogin should look
like was provided, I did a little hacking.

If I use a .hushlogin which looks like this:

.hushlogin:	/etc/motd
	cat /etc/motd
	touch .hushlogin

I get:
Make: No arguments or description file.  Stop.


I thought it might have something to do with the '.' in the
first column, so I tried:

hushlogin:      /etc/motd
        cat /etc/motd
        touch .hushlogin hushlogin

which works fine, but uses a 2nd file "hushlogin".

If I put a backslash in front of the '.' like so:

\.hushlogin:    /etc/motd
        cat /etc/motd
        touch .hushlogin 

it always cat's and touch'es.

Are there any "make" aces out there that know what's going on here?

BTW, I noticed that if you have a .hushlogin, the "You have mail"
message is also suppressed when you login, so I put the "mail"
command into my .login.

Also, even if you use "make -s -f .hushlogin" to suppress the make
chatter, make will still print out "`.hushlogin' is up to date"
when you log in and /etc/motd hasn't been changed.

I think I'll switch to someone else's suggestion and try:

cmp -s .hushlogin /etc/motd
if ($status) then
	cat	/etc/motd | tee .hushlogin
endif

then I won't have to deal with make.

____________________________________________________
|Jim Marselle           | Phone: (313) 986-1413    |
|GM Research Labs       | csnet: marselle@gmr.com  |
|Computer Science Dept. |                          |
|30500 Mound Road       |                          |
|Warren, MI  48090-9057 |                          |
----------------------------------------------------

mdb@laidbak.UUCP (Mark Brukhartz) (05/17/87)

In article <7400@brl-adm.ARPA>, MARSELLE%gmr.com@RELAY.CS.NET writes:
> The other day I read someone's suggestion to use a "make -f .hushlogin"
> in the .login file to only print out /etc/motd when its last mod time
> changes. Since no further advice regarding what .hushlogin should look
> like was provided, [ ... ].

Try the following in your csh ".login" (removing the brackets) or
or your sh ".profile" (entirely removing the bracketed items):

[set] HOST=`hostname`
echo "target: ${HOME}/.motd/${HOST} [\]
${HOME}/.motd/${HOST}: /etc/motd [\]
	@-if [ -f ${HOME}/.motd/${HOST} ]; \\
	then \\
		diff ${HOME}/.motd/${HOST} /etc/motd || true; \\
	else \\
		cat /etc/motd; \\
	fi [\]
	@cp /etc/motd ${HOME}/.motd/${HOST}" | make -f -

It generates a "makefile" on the fly in order to use absolute paths
without hard-coding the home directory name. This works around make's
problems with names which begin with dots. It uses an indirect target
to avoid "... is up to date" messages. The "true" command provides a
zero exit value in case the diff does not (... it exits nonzero when
the input files are different). To see the entire motd when there are
any differences, replace the "diff ... || true" with "cat /etc/motd".
Finally, the ${HOST} stuff prevents confusion when one login directory
is used from several machines (via NFS or the like).

I've been using a very similar script for several months. This one is
merely jazzed up a bit for near-compatibility between csh and sh.

					Mark Brukhartz
					Lachman Associates, Inc.
					..!{ihnp4, sun}!laidbak!mdb