discuss: Re: HOWTO-ROLL-YOUR-OWN-FORTUNE-COOKIES-0.0005


Previous by date: 6 Sep 2002 17:47:19 -0000 Re: FAQ about Linux, Saqib.N.Ali.seagate.com
Next by date: 6 Sep 2002 17:47:19 -0000 Writer For Hire Announcement, Charles Curley
Previous in thread:
Next in thread:

Subject: Fwd: HOWTO-ROLL-YOUR-OWN-FORTUNE-COOKIES-0.0005
From: Mark Lane ####@####.####
Date: 6 Sep 2002 17:47:19 -0000
Message-Id: <5.1.1.6.0.20020906114411.02726ec0@mail.harddata.com>

Guys,

Is anyone doing a HOWTO on Fortune Sigs?

I prepared this for our Lug so I thought I might want add it tldp for 
others to enjoy....

Mark

>HOWTO-ROLL-YOUR-OWN-FORTUNE-COOKIES-0.0005
>
>Copyright 2002 Mark Lane
>
>Report Bugs and Errors to: ####@####.#### or ####@####.####
>
>1.1     Making a fortune cookie file
>
>Now I am using Redhat and my fortunes files are found in 
>'/usr/share/games/fortune'. MDK may use
>'/usr/share/games/fortunes' as I installed a mandrake based rpm of 
>futurama quotes which placed
>it in the '/usr/share/games/fortunes'
>
>The original file used to make the randomized 'strfile' (as it is called) 
>has the following structure.
>
>file 'Quotes':
>
><file>
>Quote1
>More Quote1
>....
>%
>Quote2
>%
>Quote3
>%
></file>
>
>As you can see you place a '%' after each quotation in the file. That 
>defines the end of the quotation.
>
>you run a command
>
>% strfile -r Quotes
>
>and it makes you a random 'Quotes.dat' database file which contain header 
>information and such and is
>in a randow order.
>
>Now you want to copy your 'Quotes' and 'Quotes.dat' files into your 
>fortune directory or another
>directory if you like.
>
>To use your 'Quotes' file you would use the following command
>
>% /usr/games/fortune [/directory/Quotes/is/in/if/not/default/]Quotes
>
>1.2     Using fortune
>
>To choose from multiple fortune files say 'startrek' and 'starwars':
>
>% /usr/games/fortune startrek starwars
>
>Now if one file has more quotes than another more it will chosen more 
>often according to the ratio.
>
>(For example if startrek is 4x larger than starwars, 80% of the quotes 
>will be from the startrek
>datafile and 20% from the starwars.)
>
>Fortune can be told to ignore the size difference by assume they have the 
>same number of quotes:
>
>% /usr/games/fortune -e startrek starwars
>
>Or you can set your own ratio:
>
>% /usr/games/fortune 60% startrek 40% starwars.
>
>You can also choose from more files than 2.
>
>% /usr/games/fortune startrek starwars futurama
>
>1.3     Random fortune cookie .signature files
>
>Now some email clients will allow you to run a program to generate your 
>signature so you can create
>a short script for use in 'crontab'.
>
>signature.sh:
>
><file>
>#!/bin/sh
># make my .signature file.
>#
># usage:
># % signature.sh ['fortune command string'] [signature file] [constant 
>signature file]
>#
># Mark Lane - August 10, 2002
>#
># version 0.005
>#
># report bugs to:  ####@####.####
>#
>VERSION="0.005"
>
>function usage
>{
>    cat << EOF
>
>    $0 updates a .signature file with a fortune.
>
>    usage: $0 ['fortune command string'] [signature file] [constant 
> signature file]
>
>            --help:          displays this message
>            --version:       displays version
>
>    report bugs to:   ####@####.####
>
>EOF
>
>
>}
>
>function version
>{
>     cat << EOF
>
>$0 version: $VERSION
>
>EOF
>}
>
>case $1 in
>     --help)
>         usage
>         exit
>     ;;
>     --version)
>         version
>         exit
>     ;;
>     *)
>         if [ -z $2 ] ; then
>             $SIG=".signature"
>         else
>             SIG="$2"
>             if [ -z $3 ] ; then
>                 /usr/games/fortune $1 > $SIG
>                 exit 0
>             else
>                 if [ -f $3 ] ; then
>                     CONST="$3"
>                     cat $CONST > $SIG
>                     echo >> $SIG
>                     echo >> $SIG
>                     echo '-----' >> $SIG
>                     /usr/games/fortune $1 >> $SIG
>                     exit 0
>                 else
>                     cat <<EOF
>
>         Error: Constant Signature File Does not exist!!!
>
>EOF
>                     exit 1
>                 fi
>             fi
>         fi
>         exit
>     ;;
>esac
></file>
>
>Now use crontab to change signature
>
>To edit your crontab use "crontab -e" command. You will be editing the 
>file with vi (by default.)
>
>add line similar to the following:
>
><code>
>*/1 * * * * /usr/bin/signature.sh '-e startrek futurama starwars' \
>/home/mark/.signature /home/mark/.sig_const
></code>
>
>1.4     References & places for more info
>
>man strfile, man fortune
>
>To find premade fortune files search the net
>
>regards,
>
>Mark Lane
>
>--
>It [being a Vulcan] means to adopt a philosophy, a way of life which is
>logical and beneficial.  We cannot disregard that philosophy merely for
>personal gain, no matter how important that gain might be.
>                 -- Spock, "Journey to Babel", stardate 3842.4
>--
>Mark Lane
>Hard Data Ltd.
####@####.####
>
>Telephone: 01-780-456-9771
>FAX: 01-780-456-9772
>
>11060 - 166 Avenue
>Edmonton, AB, Canada
>T5X 1Y3
>
>http://www.harddata.com/
>--> Ask me about our Affordable Alpha Systems! <--
>
>

-- 
Mark Lane
Hard Data Ltd.
####@####.####

Telephone: 01-780-456-9771
FAX: 01-780-456-9772

11060 - 166 Avenue
Edmonton, AB, Canada
T5X 1Y3

http://www.harddata.com/
--> Ask me about our Affordable Alpha Systems! <--





Previous by date: 6 Sep 2002 17:47:19 -0000 Re: FAQ about Linux, Saqib.N.Ali.seagate.com
Next by date: 6 Sep 2002 17:47:19 -0000 Writer For Hire Announcement, Charles Curley
Previous in thread:
Next in thread:


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.