[comp.unix.questions] Suppressing the message of the day.

kbb@nancy.UUCP (05/12/87)

Is it possible to suppress the printing of the message of the day at
login? (Aside from changing login.c, that is.) I'm on 4.2/4.3 bsd.
Please respond via mail.

Karl. kbb@cs.brown.edu   {decvax,ihnp4,allegra,...}!brunix!kbb

drears@ARDEC.arpa (FSAC) (05/13/87)

-> Karl Berry writes:
-> 
-> Is it possible to suppress the printing of the message of the day at
-> login? (Aside from changing login.c, that is.) I'm on 4.2/4.3 bsd.
-> Please respond via mail.
-> 
-> Karl. kbb@cs.brown.edu   {decvax,ihnp4,allegra,...}!brunix!kbb
-> 
    The easiest way is to touch (create) a .hushlogin file in your
home directory.  It works for me on Ultrik and 4.2 systems.

Dennis  

drears@ardec

dce@mips.UUCP (David Elliott) (05/13/87)

In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) writes:
>Is it possible to suppress the printing of the message of the day at
>login? (Aside from changing login.c, that is.) I'm on 4.2/4.3 bsd.
>Please respond via mail.

This request piqued my interest. I looked to see if there was a manual
page for motd, and there wasn't (the information was in login(5)), so
I thought I'd write one. This manual page also includes a neat idea
that someone gave me a few years ago.

This manual page is hereby placed in the public domain.

-------------------------------------------------------
.TH MOTD 5
.SH NAME
motd \- Message of the day
.SH SYNOPSIS
.B /etc/motd
.SH DESCRIPTION
The file \fB/etc/motd\fP is set up to contain information about the system.
Some of the information is generated automatically.
Specifically, the system identification line (the first line of the file)
is generated at system startup time by commands in \fB/etc/rc.local\fP.
Other information is provided by the systems staff, and includes items
such as scheduled down time, information about new software and hardware,
and other timely announcements.
.PP
When a user logs in to the system via \fIlogin(1)\fP, the contents of
\fB/etc/motd\fP is printed, unless the file \fB.hushlogin\fP
exists in their home directory.
The presence of \fB.hushlogin\fP will also suppress the ``Last login...''
message (there is no way to just suppress one or the other).
.PP
Though intended for accounts such as \fIuucp\fP, for which the information
is of no value, the \fB.hushlogin\fP file can be useful.
For example, users with terminals that clear the screen upon initialization
can create \fB.hushlogin\fP and change their startup files to print the
contents of the file after terminal initialization has been done.
.PP
Another interesting idea is to create the files \fB.hushlogin\fP
and \fB.motd\fP in your home directory and place the following command
lines in the startup files
(\fB.login\fP for \fIcsh(1)\fP users, \fB.profile\fP for \fIsh(1)\fP users):
.IP
.nf
find /etc/motd -newer $HOME/.motd -exec cat {} \;
touch $HOME/.motd
.fi
.PP
This will cause the contents of the message of the day file to be printed
only when \fB/etc/motd\fP is modified.
.SH FILES
.TP 25
.I /etc/motd
The message of the day file
.TP 25
.I /etc/rc.local
System startup file
.TP 25
.I $HOME/.hushlogin
File to suppress printing of message of the day
.SH "SEE ALSO"
csh(1),
find(1),
login(1),
sh(1).
-- 
David Elliott		{decvax,ucbvax,ihnp4}!decwrl!mips!dce

daveb@rtech.UUCP (05/14/87)

In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) writes:
>Is it possible to suppress the printing of the message of the day at
>login? (Aside from changing login.c, that is.) I'm on 4.2/4.3 bsd.
>Please respond via mail.
>
>Karl. kbb@cs.brown.edu   {decvax,ihnp4,allegra,...}!brunix!kbb

As summarized,

	cd
	touch .hushlogin

will do just what you want.

-dB
-- 
{amdahl, cbosgd, mtxinu, ptsfa, sun}!rtech!daveb daveb@rtech.uucp

ejnorman@uwmacc.UUCP (Eric Norman) (05/14/87)

In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) wonders:

> Is it possible to suppress the printing of the message of the day at

My .login contains "make -f .hushlogin"; I only see it when it changes.

Eric Norman
Internet:     ejnorman@unix.macc.wisc.edu
UUCP:         ...{allegra,ihnp4,seismo}!uwvax!uwmacc!ejnorman
Life:         Detroit!Alexandria!Omaha!Indianapolis!Madison!Hyde
  
"Liberte, Egalite, Homologie."		-- Michael Henle
--

pdg@ihdev.ATT.COM (Joe Isuzu) (05/14/87)

In article <386@quacky.UUCP> dce@quacky.UUCP (David Elliott) writes:
>In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) writes:
>>Is it possible to suppress the printing of the message of the day at
>>login? 
>This request piqued my interest. I looked to see if there was a manual
>page for motd, and there wasn't (the information was in login(5)), so
>I thought I'd write one.


Good manual page, Dave.  I thought I'd add a couple of thoughts for
those on System V.  /etc/motd is cat'ed by the /etc/profile script
generally, which is executed for login shells.  Login doesn't print
the extra junk, so there is no need for a .hushlogin (uucp just uses
uucico as its default program).  As you have no choice as to whether
or not /etc/profile is run, motd will get printed unless your sysadm
adds something like this...

if [ -r "$HOME/.hushlogin" ] ; then
:
else
	cat /etc/motd
fi

-- 

Paul Guthrie
ihnp4!ihdev!pdg			This Brain left intentionally blank.

forys@sigi.Colorado.EDU (Jeff Forys) (05/15/87)

In article <1506@uwmacc.UUCP> ejnorman@unix.macc.wisc.edu (Eric Norman) writes:
> In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) wonders:
>
> > Is it possible to suppress the printing of the message of the day at
>
> My .login contains "make -f .hushlogin"; I only see it when it changes.

When what changes?  The file mod time or the *contents* of the file?  At
boot time, for example, BSD writes the current kernel rev into "/etc/motd".
Unless the machine comes up on a new kernel, "/etc/motd" will be the same,
but the mod time will have been changed.  If you want "/etc/motd" displayed
only when the contents change, you might use something like:

	cmp -s .hushlogin /etc/motd
	if ( $status ) then
		cat /etc/motd | tee .hushlogin
	endif
---
Jeff Forys @ UC/Boulder Engineering Research Comp Cntr (303-492-6096)
forys@Boulder.Colorado.EDU  -or-  ..!{hao|nbires}!boulder!forys

apn@nonvon.UUCP (root) (05/15/87)

in article <15452@brunix.UUCP>, kbb@nancy (Karl Berry.) says:
> 
> Is it possible to suppress the printing of the message of the day at
> login? (Aside from changing login.c, that is.) I'm on 4.2/4.3 bsd.
> Please respond via mail.
> 
> Karl. kbb@cs.brown.edu   {decvax,ihnp4,allegra,...}!brunix!kbb

Well.... some versions of shell look for files called (/bin/sh)

.hushlogin	which is supposed to do just this, but I have not gotten it to
		do anything usefull for me.

.broadcast	message to display at login

.profile	as usual..

------

Alex

UUCP: {ihnp4,ames,qantel,sun,seismo,amdahl,lll-crg,pyramid}!ptsfa!nonvon!apn

{* Only those who attempt the absurd   ...   will achieve the impossible   *}
{* I think... I think it's in my basement... Let me go upstairs and check. *}
{*                                                      -escher            *}

keithe@tekgvs.UUCP (05/16/87)

In article <1394@ihdev.ATT.COM> pdg@ihdev.UUCP (Joe Isuzu) writes:
>
>Good manual page, Dave.

Agreed. If you're gonna' install it where neophytes might make
use of it, alter the line describing the usage of find: escape the
backslash (which escapes the semicolon) so ms (nroff, whatever)
doesn't delete it. IN OTHER WORDS:

	find /etc/motd -newer $HOME/.motd -exec cat {} \;

has to be changed to

	find /etc/motd -newer $HOME/.motd -exec cat {} \\;

(Guess how yours truly found THIS out... :-? )

keith

dhesi@bsu-cs.UUCP (05/16/87)

In numerous articles, numerous users discuss the message of the day.
For 4.3BSD and 4.2BSD sites, I have a suggestion for all system
administrators:

     get rid of your /etc/motd

It is a waste of time to show the same worn-out message to users
every time they log in.  After a while, they will stop reading it,
and won't notice when it changes and actually shows them something
they need to know.

Instead, have each user execute "msgs -f" utility, which shows each
message only once.  This is simply done by putting that line into
the .login or .profile file when a new user account is created.

System V has a "news" program that works similarly.

Don't cry wolf.
-- 
Rahul Dhesi         UUCP:  {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi

israel@brillig.UUCP (05/17/87)

In article <1100@sigi.Colorado.EDU> forys@boulder.Colorado.EDU (Jeff Forys) writes:
>> In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) wonders:
>> > Is it possible to suppress the printing of the message of the day
>
>					  If you want "/etc/motd" displayed
>only when the contents change, you might use something like:
>
>	cmp -s .hushlogin /etc/motd
>	if ( $status ) then
>		cat /etc/motd | tee .hushlogin
>	endif

The problem with this is that first, here at our site we have a crontab
daemon that puts a greeting into the motd based on the time of day,
changing it every six hours, and second, when someone adds a new couple of
lines to the motd, I don't really want to see the parts of it that have
been around for the last couple of days.

What I did was to write the following shell script, called motdprint, that
I call from my .login.  What this shell script does is to print whatever's
been added to the motd.  You'll also see an 'egrep -v' that removes the
spurious greeting line.  Enjoy.

#! /bin/csh -f
#
# motdprint - print the changed versions of the MOTD
#	- BNI 8/18/86
#
# This script prints /etc/motd if it has been changed since the last
# time it was printed.  If it was changed, it will only print out any
# new lines, i.e. lines that were added only, not any lines that it
# would've printed out previously.
#
cd
touch .hushlogin
egrep -v 'Good morning\!|Good afternoon\!|Good evening\!|What are you doing on at this time of night?' </etc/motd >/tmp/motd.$$
cmp -s /tmp/motd.$$ .hushlogin
if (${status} != 0) then
	diff .hushlogin /tmp/motd.$$ | grep '^>' | sed -e 's/^>//'
	cp /tmp/motd.$$ .hushlogin
endif
rm -f /tmp/motd.$$

--

Bruce Israel

University of Maryland, Computer Science Dept.
seismo!mimsy!israel (Usenet)    israel@mimsy.umd.edu (Internet)

lubich@ethz.UUCP (Hannes Lubich) (05/18/87)

Rahul,
to just skip the /etc/motd file on all 4.x machines (as you propose)
isn't a sensible solution. At my site, for instance, motd contains
data that is updated every day (level, date and time of the last
dump,...). It can also be used to announce meetings for research groups
using the vcal/lcal utility posted to the net some time ago.

So the problem is the bad usage of motd, not it's existance.

Regards

	--Hannes

-- 
~ UUCP/Usenet   :   {known world}!seismo!mcvax!cernvax!ethz!lubich
~ CSNET         :   lubich%ifi.ethz.chunet@relay.cs.net
~ ARPA          :   lubich%ifi.ethz.chunet@csnet-relay.arpa                
The usual disclaimer : No, it wasn't me, somebody must have used my account.

rbj@icst-cmr.arpa (Root Boy Jim) (05/18/87)

   From: Jeff Forys <forys@sigi.Colorado.EDU>
   Date: 15 May 87 00:47:40 GMT

   In article <1506@uwmacc.UUCP> ejnorman@unix.macc.wisc.edu (Eric Norman) writes:
   > In article <15452@brunix.UUCP> kbb@brunix.UUCP (Karl Berry.) wonders:
   >
   > > Is it possible to suppress the printing of the message of the day at
   >
   > My .login contains "make -f .hushlogin"; I only see it when it changes.

   When what changes?  The file mod time or the *contents* of the file?  At
   boot time, for example, BSD writes the current kernel rev into "/etc/motd".

Or it doesn't. This is done in /etc/rc.local. Many sites have commented
this out because it is a stupid time waster. I think the idea of a
makefile is cute. 

   Unless the machine comes up on a new kernel, "/etc/motd" will be the same,
   but the mod time will have been changed.  If you want "/etc/motd" displayed
   only when the contents change, you might use something like:

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

Of course all this could be in the makefile too. Or perhaps it is
useful to know when the system is rebooted.

BTW, why not `tee .hushlogin < /etc/motd'? Who needs the cat?

   Jeff Forys @ UC/Boulder Engineering Research Comp Cntr (303-492-6096)
   forys@Boulder.Colorado.EDU  -or-  ..!{hao|nbires}!boulder!forys

	(Root Boy) Jim "Just Say Yes" Cottrell	<rbj@icst-cmr.arpa>
Well, O.K.  I'll compromise with my principles because of EXISTENTIAL DESPAIR!

P.S. Obviously Paul Guthrie is using the wrong shell on the wrong UNIX :-)

forys@sigi.Colorado.EDU (Jeff Forys) (05/18/87)

In article <7422@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
> Many sites have commented this out because it is a stupid time waster.
> I think the idea of a makefile is cute.

Where did you get these statistics?  Does a `strings /vmunix' on a reboot
waste *that* much time?  Perhaps invoking `make' from /etc/rc.local would
be quicker???

> Or perhaps it is useful to know when the system is rebooted.

Hmm, I've always used uptime(1) to determine when a machine is rebooted.
To assume the machine was rebooted every time /etc/motd changes is unwise.

> BTW, why not `tee .hushlogin < /etc/motd'? Who needs the cat?

A good idea, I will change my .login -- then again, `cat' *is* more cute!
---
Jeff Forys @ UC/Boulder Engineering Research Comp Cntr (303-492-6096)
forys@Boulder.Colorado.EDU  -or-  ..!{hao|nbires}!boulder!forys

roy@phri.UUCP (Roy Smith) (05/18/87)

In article <611@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
> get rid of your /etc/motd[...] Instead, have each user execute "msgs -f"
> utility, which shows each message only once.  This is simply done by
> putting that line into the .login or .profile file when a new user
> account is created.

	Even better, hack csh to read /usr/lib/dot-login (or whatever you
want to call it) before reading $HOME/.login like we did here.  Then you
can easily change default paths or whatever without having to tell people
to edit their .login's (many people may not even know they exist).
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

jpn@teddy.UUCP (John P. Nelson) (05/19/87)

>   you might use something like:
>
>	   cmp -s .hushlogin /etc/motd
>	   if ( $status ) then
>		   cat /etc/motd | tee .hushlogin
>	   endif

Or, more compactly:

if ! { cmp -s .hushlogin /etc/motd } tee .hushlogin < /etc/motd

mouse@mcgill-vision.UUCP (der Mouse) (05/31/87)

In article <1116@sigi.Colorado.EDU>, forys@sigi.Colorado.EDU (Jeff Forys) writes:
> In article <7422@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
>> Many sites have commented this out because it is a stupid time
>> waster.
[ nb. "this" refers to the boot-time strings on /vmunix to change the
  first line of /etc/motd ]

We commented it out, not because it was a time-waster (though it is - I
just ran it, and it took 36 cpu seconds, according to `time'), but
because /etc/motd should be the message of the day.  There is no need
to announce

4.3 BSD UNIX #81: Fri May 22 22:21:06 EDT 1987

to anyone who logs in.  "4.3 BSD UNIX" - the getty prompt has already
told them that.  "#81" - who cares about the generation count on the
UNIX.  Those who care know where to look.  "Fri May 22 22:21:06 EDT
1987" - even less do people care *when* the UNIX was generated!

If we want something in the motd, we'll put it there, thank you very
much.

> Does a `strings /vmunix' on a reboot waste *that* much time?

Yes.  Three minutes, wrist watch time, to reboot now (that's to
fastboot; a reboot with fsck takes fifteen to twenty minutes).  An
extra half-minute to put an completely uninformative message in
/etc/motd is a waste of time.

>> Or perhaps it is useful to know when the system is rebooted.
> Hmm, I've always used uptime(1) to determine [that].

And what if your local sysadmin changes /etc/motd?  Does this mean you
think the system just rebooted?  Gee, that was a quick reboot - I
didn't notice any interruption....it even left me logged in....

					der Mouse

				(mouse@mcgill-vision.uucp)

wyatt@cfa.harvard.EDU (Bill Wyatt) (06/09/87)

> We commented [ the boot-time string search for line to replace in /etc/motd ]
> out, not because it was a time-waster (though it is - I
> just ran it, and it took 36 cpu seconds, according to `time'), but
> because /etc/motd should be the message of the day.  [...]

What? On my Ultrix 1.2 uVax II, it takes 6 secs. Still, it's a waste of
time, but not much to bother with.
-- 

Bill    UUCP:  {seismo|ihnp4}!harvard!cfa!wyatt
Wyatt   ARPA:  wyatt@cfa.harvard.edu
         (or)  wyatt%cfa@harvard.harvard.edu
      BITNET:  wyatt@cfa2
        SPAN:  17410::wyatt   (this will change in June)