Re: Quote from thing
- From: Clifford Heath <no@xxxxxxxxxxxxxxx>
- Date: Mon, 20 Nov 2006 20:52:41 +1100
tomg@xxxxxxxxxxx wrote:
It might be fortune, if that is being run when he logs in. IIRC,
though, another commonly-used one, at login, was/is motd (i.e. message
of the day). I think they both just have simple text files, containing
all of the messages.
motd gives you one single message. Fortune chooses one, pseudo-randomly.
To make this thread vaguely relevant to electronics, and because I think
it's interesting. I'm going to tell you how it (the original version)
chooses one.
It uses stat() or fstat() to work out the total size of the text file in
bytes. Then it reads each multi-line message, one at a time. For each
message, it decides what fraction it represents of the remaining file
size. Then it chooses a random boolean value having that fraction as a
probability of truth, and if true, emits the message and terminates.
Thus even though the messages all vary in size, and it doesn't know how
many messages are present in advance, there's an equal chance of choosing
each one.
Well, I didn't say I expected *you* to be interested as well :-).
.
- Follow-Ups:
- Re: Quote from thing
- From: Genome
- Re: Quote from thing
- From: Andrew Holme
- Re: Quote from thing
- References:
- Quote from thing
- From: Genome
- Re: Quote from thing
- From: James T. White
- Re: Quote from thing
- From: tomg
- Quote from thing
- Prev by Date: Re: Analog vs Digital current limiting
- Next by Date: Re: The *86 CPU.
- Previous by thread: Re: Quote from thing
- Next by thread: Re: Quote from thing
- Index(es):
Relevant Pages
|