Thread View: news.software.misc
3 messages
3 total messages
Started by Robert Premuz
Sat, 25 Oct 1997 00:00
news for Ultrix
Author: Robert Premuz
Date: Sat, 25 Oct 1997 00:00
Date: Sat, 25 Oct 1997 00:00
13 lines
980 bytes
980 bytes
Is there some (simple) software which can be used by administrator of
an Ultrix 4.2 system to keep the users informed of current events in
form of short messages, for example in the way this is done by the
"news" programme on Solaris 2.x? I'd prefer some free software.
Reply by e-mail too, please.
TIA
v
-- rpr. : Robert Premuz * Email: rpremuz@public.srce.hr
http://public.srce.hr/~rpremuz/ * Voice at home: +385 (0)1 687564
Re: news for Ultrix
Author: Georg Schwarz
Date: Sun, 26 Oct 1997 00:00
Date: Sun, 26 Oct 1997 00:00
25 lines
1530 bytes
1530 bytes
Robert Premuz <rpremuz@jagor.srce.hr> wrote: > Is there some (simple) software which can be used by administrator of > an Ultrix 4.2 system to keep the users informed of current events in > form of short messages, for example in the way this is done by the > "news" programme on Solaris 2.x? I'd prefer some free software. AFAIK there is no news for Ultrix (if there is, or if someone has compiled one I'd be very interested, too). I do keep users informed the following way: - via /etc/motd for very important stuff - I've written some small shell script which when launched calles lynx with some URL where I place some information for users. The respective pages are set to be only accessible from specified local machines. -- Georg Schwarz schwarz@physik.tu-berlin.de, kuroi@cs.tu-berlin.de Institut f�r Theoretische Physik +49 30 314-24254, FAX -21130 Technische Universit�t Berlin http://home.pages.de/~schwarz/
Re: news for Ultrix
Author: Rudolf Gabler
Date: Mon, 27 Oct 1997 00:00
Date: Mon, 27 Oct 1997 00:00
312 lines
9371 bytes
9371 bytes
This is a multi-part message in MIME format.
--------------C6B71FBC113F4E66E4D37CA3
Content-Type: text/plain; charset=iso-8859-1
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Transfer-Encoding: 8bit
I had the same question some time before and use the following perl
version (attachment)
since years now.
Best regards,
Rudi Gabler
Georg Schwarz wrote:
> Robert Premuz <rpremuz@jagor.srce.hr> wrote:
>
> > Is there some (simple) software which can be used by administrator
> of
> > an Ultrix 4.2 system to keep the users informed of current events in
>
> > form of short messages, for example in the way this is done by the
> > "news" programme on Solaris 2.x? I'd prefer some free software.
>
> AFAIK there is no news for Ultrix (if there is, or if someone has
> compiled one I'd be very interested, too).
> I do keep users informed the following way:
>
> - via /etc/motd for very important stuff
>
> - I've written some small shell script which when launched calles lynx
>
> with some URL where I place some information for users. The respective
>
> pages are set to be only accessible from specified local machines.
>
> --
> Georg Schwarz schwarz@physik.tu-berlin.de, kuroi@cs.tu-berlin.de
> Institut f�r Theoretische Physik +49 30 314-24254, FAX -21130
> Technische Universit�t Berlin http://home.pages.de/~schwarz/
--------------C6B71FBC113F4E66E4D37CA3
Content-Type: text/plain; charset=us-ascii; name="news"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="news"
#!/usr/local/bin/perl
'di';
'ig00';
#!/usr/local/bin/perl
require "ctime.pl";
# Configuration
($whatami = $0) =~ s|.*/||; # `basename $0`
$home = $ENV{'HOME'} || (getpwuid($<))[7] ||
die "$whatami: Can't find your home directory.\n";
$news_dir = '/usr/local/news';
$news_times = "$home/.news_times";
$todo = ''; # Default action
$all = 0; # Operate on new news
$page = $pause = -t STDOUT; # Page and pause only on a tty
$pager = $ENV{'PAGER'} || 'more';
$SIG{'PIPE'} = 'IGNORE'; # Ignore 'broken pipe'
$| = 1; # Buffering breaks "\r" hack
# Process args, setting $todo, $all, $page, and $pause. I can't use one of
# the packages because they don't preserve switch order.
while (($first, $rest) = ($ARGV[0] =~ /^-(.)(.*)/)) {
if ($first =~ /m|n|s/) { $todo = $first; }
elsif ($first eq 'a') { $all = 1; }
elsif ($first eq 'c') { $page = 0; }
elsif ($first eq 'p') { $pause = 0; }
else { die "$whatami: $first is not an option.\n"; }
if ($rest ne '') {
$ARGV[0] = "-$rest";
} else {
shift;
}
}
# Read owners and ctimes of $news_dir/* into %news_uid and %news_dir
opendir(NEWS_DIR, $news_dir) ||
die "$whatami: Can't find the news directory, $news_dir.\n";
foreach (grep(!/^\.\.?$/, readdir NEWS_DIR)) {
($news_uid{$_}, $news_dir{$_}) = (stat("$news_dir/$_"))[4,9];
}
closedir NEWS_DIR;
# Read ~/.news_times into %news_times if necessary
unless (($all || @ARGV) && $todo =~ /[ns]/ || ! -e $news_times) {
open(news_times) || die "$whatami: Couldn't open $news_times; $!.\n";
while(<news_times>) {
/([^ ]*) ([^ \n]*)/;
$news_times{$1} = $2;
}
close news_times;
}
# Put all news, args, or new news in @items
if ($all) { # Operate on all news,
@items = sort by_value keys %news_dir;
} elsif (@ARGV) { # args, or
foreach (@ARGV) {
if (-e "$news_dir/$_") {
push(@items, $_);
} else {
push(@bad, $_);
}
}
if ($#bad == 0) {
warn "$whatami: There is no news item named $bad[0].\n";
} elsif ($#bad > 0) {
warn "$whatami: There are no news items named ",
join(", ", @bad[0 .. $#bad - 1]), " or $bad[$#bad].\n";
}
} else { # new news.
foreach (sort by_value keys %news_dir) {
push(@items, $_) if $news_dir{$_} > $news_times{$_};
}
}
# Operate on @items
if ($todo eq 'n') { # List,
print "$whatami: @items\n" if @items;
} elsif ($todo eq 's') { # count, or
print $#items + 1, ' news item',
$#items ? 's' : '', ".\n";
} else { # mark or show and mark, then write.
if ($todo eq 'm') { # Mark @items in %news_times
foreach (@items) {
$news_times{$_} = $news_dir{$_}; # Mark item in %news_times
}
} else { # Show @items
if ($pause && $ENV{'TERM'}) { # Highlight prompts if we know TERM
$smso = `tput smso`; # Bold on
# $smso = '2\x1b[1m';
$rmso = `tput rmso`; # Bold off
# $rmso = '2\x1b[m';
}
&pageon if $page && ! $pause;
$many = @items;
while ($item = shift @items) {
&pageon if $page && $pause;
open(ITEM, "$news_dir/$item") || # Open, print, and close item
die "$whatami: Can't open $news_dir/$item; $!.\n";
print "$item (", (getpwuid($news_uid{$item}))[0], ') ',
&ctime($news_dir{$item}), "\n";
print " $line" while $line = <ITEM>;
print "\n";
close ITEM;
&pageoff if $page && $pause;
$news_times{$item} = $news_dir{$item}; # Mark item in %news_times
if ($page && $pause && @items) { # Pause and prompt.
print $smso, 'Any key for item ', $many - $#items,
" of $many or q to quit:$rmso ";
$getkey = &getkey;
print "\r", ' ' x 50, "\r"; # Clean up after pause prompt
last if $getkey =~ /q/i; # User hit q
}
}
&pageoff if $page && ! $pause;
}
open(NEWS_TIMES, ">$news_times") || # Write updated %news_times
die "$whatami: Couldn't write $news_times; $!.\n";
foreach (keys %news_times) {
# Write %news_times entries only if they're also in %news_dir
print NEWS_TIMES "$_ $news_times{$_}\n" if $news_dir{$_};
}
close NEWS_TIMES;
}
exit @bad; # Exit with return value @bad;
sub by_value { # Sort numerically by $news_dir{$x},
# then alphabetically by $x.
$news_dir{$b} <=> $news_dir{$a} || $a cmp $b;
}
sub getkey { # This routine is very expensive but is
system('stty -echo raw opost'); # the simplest way to get a single char
local($key) = getc; # from the keyboard in Perl under IRIX.
system('stty echo -raw'); # See the Perl FAQ for better but more
return($key); # complex ways and for other systems.
}
sub pageon { # Turn on paging.
open(PAGE, "| $pager") || # Assumes $pager and $whatami.
die "$whatami: Can't open pager $pager; $!.\n";
select PAGE;
$| = 1; # Buffering breaks "\r" hack
}
sub pageoff { # Turn off paging.
select STDOUT;
close PAGE;
}
.00;
'di
.nr nl 0-1
.nr % 0
'; __END__
.TH NEWS 1L
.SH NAME
news \- print news items
.SH SYNOPSIS
\fBnews\fR [ \fB-acp\fR ] [ \fB-m\fR | \fB-n\fR | \fB-s\fR ] [ item(s) ]
.SH DESCRIPTION
\fInews\fR lets one read the news items stored in \fI/usr/local/news\fR.
One can do this in several ways:
news
prints unread news items, newest first, and marks them read.
news item(s)
prints each item, read or unread, and marks it read.
news -a
prints all news items, read or unread, and marks them read.
.SH OPTIONS
If more than one of \fB-m\fR, \fB-n\fR or \fB-s\fR is given, only the
last works.
.TP 4
.B -m
Mark news items as read without printing them.
.TP 4
.B -n
List the names of news items.
.TP 4
.B -s
Count news items.
.TP 4
.B -a
Operate on (print, mark, list or count) all news items, read or unread.
.TP 4
.B -c
Don't use a pager or pause between news items. \fInews\fR assumes \fB-c\fR when
not on a tty.
.TP 4
.B -p
Don't pause between news items.
.SH ENVIRONMENT
.PD 0
.TP 17
.B HOME
The directory in which \fInews\fR looks for \fI.news_times\fR.
.TP 17
.B PAGER
The pager to which output is sent. The default is \fImore\fR(1).
.PD
.SH FILES
.PD 0
.TP 17
/usr/local/news
The directory in which news items are kept. Make this directory mode 041777
(drwxrwxrwt) so that any user can make their own news items but can't remove
or change other users' news items.
.TP 17
\\.news_times
The file in which the date of each read news item is kept.
.PD
.SH ERRORS
\fInews\fR returns the number of items which were specified on the command
line but not found, or, after a fatal error, the system error number.
.SH "SEE ALSO"
more(1), news(1)
.SH AUTHOR
Dave Schweisguth (dcs@neutron.chem.yale.edu). Perl, which does most of the
work, is by Larry Wall.
.SH HISTORY
This version of \fInews\fR is based on, and is intentionally only slightly
more useful than, the standard IRIX program of the same name.
--------------C6B71FBC113F4E66E4D37CA3--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads