[comp.unix.questions] .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 |                          |
----------------------------------------------------

dce@mips.UUCP (05/16/87)

In article <7407@brl-adm.ARPA> MARSELLE%gmr.com@RELAY.CS.NET writes:
>
>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.
>

This is very obscure, but documented (I don't remember where, but I
found it when I was rewriting the make manual page at Tektronix).

The idea is that the "default target" is the first target in the file
that does not begin with a '.'. This is done so that you can do
things like

	.SUFFIXES: .c .s ...
	...
	all: $(PGM)
	...

and be able to say 'make' and mean 'make all'.

The easiest solution is to add the line

	all: .hushlogin

at the end of the file, so you end up with:

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

	all: .hushlogin

(The '@-' tells make to ignore exit codes and to not print the
data.)

Still, all this is no better than

	find /etc/motd -newer .hushlogin -exec cat '{}' \;
	touch .hushlogin

If you really want to see /etc/motd when it changes, use the "cmp"
stuff.
-- 
David Elliott		{decvax,ucbvax,ihnp4}!decwrl!mips!dce

dhesi@bsu-cs.UUCP (Rahul Dhesi) (05/17/87)

In article <7407@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.
[discussion of many variations of this, leading to:]
>I think I'll switch to someone else's suggestion and try [something else.]

Here is a solution I actually used for some years with 4.2BSD:

     find /etc -name motd -newer .hushlogin \
        -a -exec cat /etc/motd \; \
        -a -exec touch .hushlogin

On the face of it this could be ineffeicient.  But since /etc turns out
to have no subdirectories (under 4.2BSD) it's actually pretty fast.
Please check the syntax since I am quoting from memory.

The real solution is:

     GET RID OF THAT /ETC/MOTD!!!  Use a sensible one-time message
     utility like "msgs" (4.xBSD) or "news" (System V).
-- 
Rahul Dhesi         UUCP:  {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi

sbanner1@uvicctr.UUCP (05/22/87)

In article <7407@brl-adm.ARPA> MARSELLE%gmr.com@RELAY.CS.NET writes:
>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 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

This is the first thing in my .login, and I have a null .login.  I have
had no problems with it.  I only get the message when the file changes.

# Check for the message of the day.
find /etc/motd -newer ~/.hushlogin -exec cat /etc/motd \;
touch ~/.hushlogin

                      S. John Banner

...!uw-beaver!uvicctr!sol!sbanner1
...!ubc-vision!uvicctr!sol!sbanner1
ccsjb@uvvm
sbanner1@sol.UVIC.CDN

brandon@tdi2.UUCP (Brandon Allbery) (05/23/87)

Quoted from <7407@brl-adm.ARPA> [".hushlogin"], by MARSELLE%gmr.com@RELAY.CS.NET...
+---------------
| 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.
+---------------

A make rule starting with a period is a generic rule for converting a file
with some suffix to a file with another suffix (or a file with no suffix).
Thus, make sees a rule to convert xxx.hushlogin to xxx for any xxx, but no
other commands to actually do anything.  Backslashing the `.' makes it a
normal (i.e. specific) rule, so make has something to do.

+---------------
| 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.
+---------------

A ``kluge'' I use to get around this is:

all: foo
foo: (dependencies and commands)

Actually, `all' may be any file you don't have.  Since there is no file `all'
and your rules don't create one, make is silent about its (non)existence.

++Brando
-- 
Brandon S. Allbery	           UUCP: cbatt!cwruecmp!ncoast!tdi2!brandon
Tridelta Industries, Inc.         CSNET: ncoast!allbery@Case
7350 Corporate Blvd.	       INTERNET: ncoast!allbery%Case.CSNET@relay.CS.NET
Mentor, Ohio 44060		  PHONE: +1 216 255 1080 (home +1 216 974 9210)