Debian Codegraph @

util/README.randstr

raw
1 randstr is a simple utility that implements the minimal functionality of
2 the fortune program. Give it the name of a strfile text or data
3 (pointer) file, and it will randomly select and print one text string.
4
5 It isn't intended to do a lot; it's supposed to be a sample
6 implementation of a minimal strfile type random text retrieval function,
7 such as might be used to generate random .signature files.
8
9 For example:
10
11 Create a file of signatures in strfile format (none more than four lines
12 long, please!). Call it signatures, for ease of understanding.
13
14 Run it through strfile to create the pointer file; put both files in a
15 safe place--your home directory, for instance.
16
17 In your .login or .profile, add the line:
18 randstr $HOME/signatures >.signature
19
20 Each time you log in, your signature will change randomly to one of those
21 in the file signatures. If you change the file, be sure to update the
22 pointers file! (use strfile)
23
24 If you happen to have root privileges, you might be able to hack Pnews
25 to change the sig randomly whenever you post. The solution is left as
26 an exercise for the student (gee, I *always* wanted to say that!).
27
28 Another example:
29
30 As root, create a shell or Perl script to read /etc/passwd and create
31 a strfile text file containing login name (line one) and GECOS (line
32 two).
33
34 Add an entry to crontab.root that runs that script once a month, then
35 uses strfile to create the data file, and randstr to select one entry
36 at random.
37
38 Give valuable prizes to the winning login. The script can also auto-mail
39 to the user, with Cc: root.
40
41 Any other 'lottery'-style function could be implemented the same way.
42
43 Both of these examples are more easily implemented with randstr (which
44 doesn't care where the files are, and accepts no parameters) than with
45 fortune, which expects files to be in a place specified at compile-time.
46
47 Amy A. Lewis [email protected]