From owner-freebsd-questions@FreeBSD.ORG Mon Aug 25 11:02:34 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15BDA16A4BF for ; Mon, 25 Aug 2003 11:02:34 -0700 (PDT) Received: from webserver.get-linux.org (adsl-64-161-78-226.dsl.lsan03.pacbell.net [64.161.78.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 5EBA143FEA for ; Mon, 25 Aug 2003 11:02:33 -0700 (PDT) (envelope-from oremanj@webserver.get-linux.org) Received: (qmail 9116 invoked by uid 1000); 25 Aug 2003 18:02:55 -0000 Date: Mon, 25 Aug 2003 11:02:55 -0700 From: Joshua Oreman To: freebsd-questions@FreeBSD.org Message-ID: <20030825180255.GB8753@webserver> Mail-Followup-To: freebsd-questions@FreeBSD.org, questions@freebsd.org References: <20030825163744.GA61150@keyslapper.org> Mime-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20030825163744.GA61150@keyslapper.org> User-Agent: Mutt/1.4.1i cc: questions@freebsd.org Subject: Re: motd question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Aug 2003 18:02:34 -0000 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 ; 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 => <>' line. If you have two (or more) of these things running, it can produce unexpected results. Be careful. -- Josh > > TIA > Lou > -- > Louis LeBlanc leblanc@keyslapper.org > Fully Funded Hobbyist, KeySlapper Extrordinaire :) > http://www.keyslapper.org ԿԬ > > Make it right before you make it faster. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"