Re: motd question

2003-08-26 Thread Joshua Oreman
On Mon, Aug 25, 2003 at 11:02:55AM -0700 or thereabouts, Joshua Oreman wrote:
 On Mon, Aug 25, 2003 at 12:37:44PM -0400 or thereabouts, Louis LeBlanc wrote:
  Probably not possible, but I was wondering (and have for some time,
  though I can't find any info on it either way) whether /etc/motd is
  strictly a text in/text out file, or if there is a way to get it to
  execute a command, the output of which is to be included in the text
  output?
 
 You could make it a FIFO and put a Perl script or something at the
 other end, if you want dynamically-generated output.
 [ ... ]
 Be careful.

Really! This approach can come back and bite you in the butt. Basically, be absolutely
sure the writer process is started during bootup. Otherwise it'll hang indefinitely
when logging in; you need to drop to single-user to fix it.

-- Josh

 
  
  TIA
  Lou
  -- 
  Louis LeBlanc   [EMAIL PROTECTED]
  Fully Funded Hobbyist, KeySlapper Extrordinaire :)
  http://www.keyslapper.org ԿԬ
  
  Make it right before you make it faster.
  ___
  [EMAIL PROTECTED] mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-questions
  To unsubscribe, send any mail to [EMAIL PROTECTED]
 ___
 [EMAIL PROTECTED] mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: motd question

2003-08-26 Thread Louis LeBlanc
On 08/26/03 01:20 PM, Joshua Oreman sat at the `puter and typed:
 On Mon, Aug 25, 2003 at 11:02:55AM -0700 or thereabouts, Joshua Oreman wrote:
  On Mon, Aug 25, 2003 at 12:37:44PM -0400 or thereabouts, Louis LeBlanc wrote:
   Probably not possible, but I was wondering (and have for some
   time, though I can't find any info on it either way) whether
   /etc/motd is strictly a text in/text out file, or if there is a
   way to get it to execute a command, the output of which is to be
   included in the text output?
  
  You could make it a FIFO and put a Perl script or something at the
  other end, if you want dynamically-generated output.  [ ... ] Be
  careful.
 
 Really! This approach can come back and bite you in the butt.
 Basically, be absolutely sure the writer process is started during
 bootup. Otherwise it'll hang indefinitely when logging in; you need
 to drop to single-user to fix it.

Yeah, I really just wanted to get the output of an alias, but it's not
important enough to go through all that for.

I just figured it would be a pretty cool - although quite geeky thing
to have the real time printed out with each login:

The alias is as follows:
$ gtime

Right now, the official U.S. time is:
  16:20:43
  Tuesday, August 26, 2003

and it's expansion is:
$ alias gtime 
alias gtime='lynx -dump http://www.time.gov/timezone.cgi?Eastern/d/-5 | head -5'

Pretty interesting, but definitely not worth the hassle that would
obviously be required.

Thanks for the feedback everyone.

Lou
-- 
Louis LeBlanc   [EMAIL PROTECTED]
Fully Funded Hobbyist, KeySlapper Extrordinaire :)
http://www.keyslapper.org ԿԬ

QOTD:
  It's sort of a threat, you see.  I've never been very good at
  them myself, but I'm told they can be very effective.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


motd question

2003-08-25 Thread Louis LeBlanc
Probably not possible, but I was wondering (and have for some time,
though I can't find any info on it either way) whether /etc/motd is
strictly a text in/text out file, or if there is a way to get it to
execute a command, the output of which is to be included in the text
output?

TIA
Lou
-- 
Louis LeBlanc   [EMAIL PROTECTED]
Fully Funded Hobbyist, KeySlapper Extrordinaire :)
http://www.keyslapper.org ԿԬ

Make it right before you make it faster.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: motd question

2003-08-25 Thread Chuck Swiger
Louis LeBlanc wrote:
Probably not possible, but I was wondering (and have for some time,
though I can't find any info on it either way) whether /etc/motd is
strictly a text in/text out file, or if there is a way to get it to
execute a command, the output of which is to be included in the text
output?
/etc/motd is a text file, and is displayed due to the following section 
/etc/login.conf:

default:\
:passwd_format=md5:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\
FYI, most other flavors of Unix have a cat /etc/motd in the default shell init 
files.  Anyway, if you want to dynamicly generate motd, you could invoke your 
program via cron or simply put something in /etc/profile which will display 
whatever it is you want to see (if for all users), or in ~/.profile [ ~/.login, 
~/.zlogin, etc]

--
-Chuck
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: motd question

2003-08-25 Thread Joshua Oreman
On Mon, Aug 25, 2003 at 12:37:44PM -0400 or thereabouts, Louis LeBlanc wrote:
 Probably not possible, but I was wondering (and have for some time,
 though I can't find any info on it either way) whether /etc/motd is
 strictly a text in/text out file, or if there is a way to get it to
 execute a command, the output of which is to be included in the text
 output?

You could make it a FIFO and put a Perl script or something at the
other end, if you want dynamically-generated output. For example:
--snip--
#!/usr/bin/env perl
use constant FILE = /etc/motd;
use POSIX qw/setsid mkfifo/;

# Comment these if you want it to run in foreground:
exit 0 if fork;
setsid;

while (1) {
unless (-p FILE) {
unlink FILE;
mkfifo FILE, 0644;
}

my $fortune_msg;

open FORTUNE, /usr/bin/env fortune | or die Can't open pipe from fortune: 
$!\n;
$fortune_msg .= $_ while FORTUNE;
close FORTUNE;

open FIFO, .FILE or die Can't open .FILE. for writing: $!\n;
print FIFO $fortune_msg;
close FIFO;

sleep 2;
}
--snip--
would generate a `fortune' message every time someone read motd. Run it like so:
# /path/to/fortunemotd.pl

Note that this script will *DELETE YOUR EXISTING MOTD*... back it up first.

If you want to use this for something else, for example a .signature, change
the `use constant FILE = the-file-goes-here-in-quotes' line.

If you have two (or more) of these things running, it can produce unexpected results.
Be careful.

-- Josh

 
 TIA
 Lou
 -- 
 Louis LeBlanc   [EMAIL PROTECTED]
 Fully Funded Hobbyist, KeySlapper Extrordinaire :)
 http://www.keyslapper.org ԿԬ
 
 Make it right before you make it faster.
 ___
 [EMAIL PROTECTED] mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]