[mod.computers.vax] login news routine for VAX/VMS

perry@VU-VLSI.UUCP (Rick Perry) (03/09/86)

( I tried posting this about a month ago by using 'followup' command
in vnews in group mod.computers.vax, and it said 'mail sent' but I'm not
sure where it went or if it got there... so if this is a duplication or
just not of interest, please trash it!)
----------
   On our VAX/VMS systems, the login news.txt stuff started to get very
long and boring, since it took up about 2 screens and wasn't even updated
frequently; everyone was getting into the habit of pressing CTRL/O after
login; then, when news was updated, we wouldn't even know it!

   Anyway, our system manager uses 4 news files: news.clu (cluster news),
schedule.txt (current schedule of operation), hints.txt (tips for dummies),
and news.gen (general news).  He devised a scheme (the .com appears at
end of this msg) so that users would only see the news files if they had
been updated since last login; I wrote my own version (which I think is
better, of course!), so I'm just posting it here so it won't go completely
to waste...
-----
$! NEWS.COM   ...!{pyrnj,psuvax1}!vu-vlsi!perry   2/9/86
$
$newslist := sys$manager:news.clu/sys$manager:schedule.txt/-
	     sys$manager:hints.txt/sys$manager:news.gen
$
$login := sys$login:login.com
$
$count	= 0
$new	= 0
$
$! if user login.com file does not exist,
$!  then create it and display the news
$if f$search(login) .eqs. "" then goto create
$
$! get modification time of user login.com
$user_time=f$file_attributes(login,"rdt")
$user_time=f$cvtime(user_time)
$
$mloop:
$newsfile = f$element(count,"/",newslist)
$if newsfile .eqs. "/" then goto finish
$
$! get creation time of newsfile
$sys_time=f$file_attributes(newsfile,"cdt")
$sys_time=f$cvtime(sys_time)
$
$! compare the two times
$if user_time .ges. sys_time then goto skip ! user has already seen this one
$
$new = new + 1
$write sys$output ""
$type 'newsfile'
$
$skip:
$count = count + 1
$goto mloop
$
$finish:
$if new .eq. 0 then exit
$
$! update user login.com modification time,
$!  without actually modifying the file
$set protection=('f$file_attributes(login,"pro")') 'login'
$exit
$
$create:
$! create user login.com file
$ copy nl: 'login'
$
$! display all the news files
$count = 0
$dloop:
$newsfile = f$element(count,"/",newslist)
$if newsfile .eqs. "/" then exit
$write sys$output ""
$type 'newsfile'
$count = count + 1
$goto dloop
-----
Here's the version currently running on our systems... should be posted to
net.jokes probably; requires user to have a NEWS_SYSTEM.DAT file, which
looks typically like:

31-OCT-1985 16:52:50.54
 6-FEB-1986 11:45:32.18
 4-DEC-1985 15:19:20.17
10-FEB-1986 15:04:48.22
-----
$ set nocontrol=y
$ set mess/notex/nofac/nosev/noident
$ on error then goto print
$ open/read       rdn    news_system.dat.1
$ open/writ       rdn2   news_system.dat.2
$ cluster:
$ tmp=f$file("sys$manager:news.clu","rdt")
$ write           rdn2   tmp
$ read/end=schedule rdn rec
$ if rec.eqs.tmp then goto SCHEDULE
$ type            sys$manager:news.clu
$ schedule:
$ tmp=f$file("sys$manager:schedule.txt","rdt")
$ write           rdn2   tmp
$ read/end=hints    rdn  rec
$ if rec.eqs.tmp then goto hints
$ type            sys$manager:schedule.txt
$ hints:
$ tmp=f$file("sys$manager:hints.txt","rdt")
$ write           rdn2   tmp
$ read/end=general  rdn  rec
$ if rec.eqs.tmp then goto general
$ type            sys$manager:hints.txt
$ general:
$ tmp=f$file("sys$manager:news.gen","rdt")
$ write           rdn2   tmp
$ read/end=exit     rdn  rec
$ if rec.eqs.tmp then goto exit
$ type            sys$manager:news.gen
$ exit:
$ close rdn
$ close rdn2
$ purge news_system.dat
$ renam news_system.dat; news_system.dat.1
$ set mess/tex/fac/sev/ident
$ set control=y
$ exit
$ print:
$ ty sys$manager:news.txt
$ ty sys$manager:news.gen
$ set mess/tex/fac/sev/ident
$ set control=y
-----
   I guess the thing that bothers me most about the above .com is that it
constantly creates a new news_system.dat file and does the purge & rename
everytime you login; in my version, the only file touched is the user's
login.com which get's its modification time updated only if there is some
new news.

...Rick		...{pyrnj,psuvax1}!vu-vlsi!perry