summaryrefslogtreecommitdiff
path: root/content/fortunes/fortune-cookies-HOWTO.sgml
blob: 7bf6a890879a6f90b4ce34d279c55dd6b29aa07f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!doctype linuxdoc system>

<article>

<title>Fortune Mini-HOWTO (english)</title>
<author>Walter Harms </author>
<date>Version 0.01, 19.05.2004</date>

<abstract>
How to use use fortune to generate cookies. 
</abstract>

<toc>

<sect>Introduction
<p>
When a user logs into a system normally the /etc/motd is displayed. ( You can
disable this by creating the file &tilde;/.hushlogin.) You will be greeted
by something like ''welcome to 127.0.0.1''. That is boring.

Here comes ''fortune'' to the rescue. The package comes with 3 programs:
fortune,strfile and unstr. 

<sect>Usage of fortune, strfile and unstr
<p>
The programs have clear distinguished jobs: presentation, assembly and
disassembly of the fortune databases. 

<sect1>Fortune
<p>
fortune is the presenter program. A simple application is to call the
program in the crontab and modify the /etc/motd. e.g.:
<code>
 */10 * * * * /usr/bin/fortune >/etc/motd

To select a given database with quotes simply add the database as argument.

 */10 * * * * /usr/bin/fortune myquotes >/etc/motd
</code>
You can also specify more than one database file. Then fortune will consider
both files equally often.
<code>

> fortune  myquotes  startrek
</code>
Some people like some quotes more than others. So your can manipulate the
equilibrium by adding probabilities.
<code>

> fortune  90% myquotes  10% startrek
</code>
fortune has some additional command line switches but its beyond the
scope of this document to explain them. check the man page instead.

<sect1>generating a fortune database
<p>
Now we come to terms. Pick a list of quotes. There are several sources.
Of cause the Internet will provide you with a long list. Choose quotes
you like they will appear regularly now. Collect the quotes in one file.
Every quote separated with a line containing a single  &percnt; e.g.:
<code>
quote 1
%
quote 2
%
quote 3
%
quote 5
</code>
This is not a very effective way. Therefor is the strfile program.It will
process the ASCII-file and add a binary helper. The &lt;myquotes&gt; will 
accompanied by &lt;myquotes&gt;.dat .
<code>

> strfile myquotes
</code>
The &lt;myquotes&gt;.dat will by copied into the directory where the datafiles are stored.
This is usually <tt>/usr/share/fortune</tt>. Check the installation with:
<code>
>fortune myquotes
</code>

<sect1> unstr
<p>
This is what the man-page says:
<code>
The purpose of unstr is to undo the work of strfile.  It prints out the
strings contained in the file source_file in the order that they are
listed in the header file source_file.dat to standard output.  It is 
possible to create sorted versions of input files by using -o when strfile
is run and then using unstr to dump them out in the table order.
</code>

<sect> other files to have fun with
<p>
An other possible target is <tt>.signature</tt>. 
Any selfrespecting mailprogram will add that to an outgoing mail.

<sect> remarks
<p>
The patchnames mentioned here are based on the actual fortune package.
Distribution may change the place to somewhere.
<p>
Beside fortune there are several other programs that select random
quotes from a database. 
<p>
Be carefull when choosing quotes. There are people who take them serious like:
<code>
====### legal notice ###====-------------------------------------------
Microsoft Network is prohibited from redistributing this work in any form, in
whole or in part.  License to distribute this post is available to Microsoft
for $499.  Posting without permission constitutes an agreement to these terms.
walter@linux:~/bericht/fortune> fortune myquotes
"You  have the right to remain silent, but I wouldn't encourage you to do
 so.  Anything you say will be taken down, altered to my satisfaction and
 used in a court of law to send you down for a good many years!"
</code>

</article>