fortune

Python version of old BSD Unix fortune program
Download

fortune Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Brian M. Clapper
  • Publisher web site:
  • http://www.clapper.org/

fortune Tags


fortune Description

Python version of old BSD Unix fortune program fortune is a stripped-down implementation of the classic BSD Unix fortune command, in Python. It combines the capabilities of the strfile command (which produces the fortune index file) and the fortune command (which displays a random fortune). It reads the traditional fortune program's text file format.Usage:fortune /path/to/fortunesOPTIONS-h, --help Show usage and exit.-u, --update Update the index file.-q, --quiet When updating the index file, do so quietly.-V, --version Show version and exit.If you omit the path, fortune looks at the FORTUNE_FILE environment variable. If that environment variable isn't set, fortune aborts.Fortune Cookie File FormatA fortune cookie file is a text file full of quotes. The format is simple: The file consists of paragraphs separated by lines containing a single '%' character. For example:A little caution outflanks a large cavalry. -- Bismarck%A little retrospection shows that although many fine, useful softwaresystems have been designed by committees and built as part of multipartprojects, those software systems that have excited passionate fans arethose that are the products of one or a few designing minds, greatdesigners. Consider Unix, APL, Pascal, Modula, the Smalltalk interface,even Fortran; and contrast them with Cobol, PL/I, Algol, MVS/370, andMS-DOS. -- Fred Brooks, Jr.%A man is not old until regrets take the place of dreams. -- John BarrymoreThe Index FileFor efficiency and speed, fortune uses an index file to store the offsets and lengths of every fortune in the text fortune file. So, before you can use fortune to read a random fortune, you have to generate the data file. With the traditional BSD fortune program, you used the I{strfile}(8) command to generate the index. With I{this} fortune program, however, you simply pass a special argument to the fortune command:fortune -u /path/to/fortunesThat command will generate a binary /path/to/fortunes.dat file that contains the index. You should run fortune -u whenever you change the text fortune file.Generating a Random FortuneOnce you have an index file, you can generate a random fortune simply by running the fortune utility with the path to your text fortunes file:fortune /path/to/fortunesDifferencesThis version of fortune does not provide some of the more advanced capabilities of the original BSD program. For instance, it lacks: * the ability to mark offensive and inoffensive fortunes * the ability to separate long and short quotes * the ability to print all fortunes matching a regular expressionIt does, however, provide the most important function: The ability to display a random quote from a set of quotes. Requirements: · Python


fortune Related Software