Skip to main content

Python version of old BSD Unix fortune program

Project description

Introduction

fortune is a stripped-down implementation of the classic BSD Unix fortune command. 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

Usage:

fortune [OPTIONS] /path/to/fortunes

OPTIONS

-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.

The Index File

For 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/fortunes

That 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 Fortune

Once 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/fortunes

Differences

This 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 expression

It does, however, provide the most important function: The ability to display a random quote from a set of quotes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

fortune-0.5.1.zip (11.3 kB view details)

Uploaded Source

fortune-0.5.1.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file fortune-0.5.1.zip.

File metadata

  • Download URL: fortune-0.5.1.zip
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fortune-0.5.1.zip
Algorithm Hash digest
SHA256 f724fc37b725e549b8ea0e6a874cf09d8a25cd3eb84a5a4bf44710c99c0c69ce
MD5 a491b1fa293ff037019b01f5ff278603
BLAKE2b-256 fb53843b5224b1be1c4d4870ab848eee61c6f2a004083359c6f6f741986952af

See more details on using hashes here.

File details

Details for the file fortune-0.5.1.tar.gz.

File metadata

  • Download URL: fortune-0.5.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fortune-0.5.1.tar.gz
Algorithm Hash digest
SHA256 27306183189b844d747c6005e6ac49720b72175e646e74b297c9d5b6c4cd54e8
MD5 493ccbd320d5c821cb882b70060ce14a
BLAKE2b-256 f4ee3c475b74526a18e6e36769bad8c4a805385892eb66c0a207ab09d6643efd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page