HowTo: Create Fortune Files

With these steps you should be able to create your own fortune files, which can be used with the Fortune Widget I created for WordPress. This does get a little tricky for Windows users, as the applications needed to create these files are not as readily available as in Linux, but hopefully it shouldn’t be to painful.

So first create a text file with all of your quotes separated by a ‘%’:

Example:

I reject your reality and substitute my own...
%
This is one of those "What the hell am I doing?" moments, over!
%
We got a robot in the water, he's stuffed with tuna and it's just another day here at Mythbusters.

In this example I named the file “quotes”. Now we need to create the .dat random-access data file, to assist the fortune application or any fortune based scripts / apps in randomly selecting a quote.

In Linux, as long as you have installed the fortune-mod package you can execute the following to create your .dat file:

strfile quotes quotes.dat

Here are a few examples of how to get the fortune-mod package on your Linux installation:
Debian: apt-get install fortune-mod
Fedora: yum install fortune-mode
Gentoo: emerge fortune-mod

In Windows, you have a few options, all of which require a few steps. First you could install cygwin, which is a Unix system overlay that can install onto Windows giving you basic to extensive Unix functionality (even X11). During the installation you can select fortune-mod as a package you wish to have installed, giving you access to the same strfile command listed previously.

Another Windows option is, if you have or don’t mind installing python, I came across a python interpretation of the strfile command.

Then, last but not least, there is a fairly old application written for Windows95 (which some people claim to still work) called wFortune. This app includes a windows viewer, and a dos executable strfile.

Now that you have created your fortune file, lets install this to where your Fortune Widget can use it. First, make sure you have the Fortune Widget properly installed into your WordPress plugins directory. As of this post, the widget was designed for the original automatic widgets plugin. Once the plugin is available in your WordPress widgets manager, copy the fortune file just created into the fortune directory under plugins:

cp quotes quotes.dat ~/www/wordpress/plugins/fortune/quotes.dat

Now, bring up the customization window for the Fortune widget under the WordPress widgets manager. From her you can set a title, and you should be able to select your newly created fortune file.

If you have any questions, definitely comment, otherwise I plan to have better instructions on my next release, as the Fortune Widget 0.3 still needs to be updated for WordPress 2.2.x.

I hope that helps everyone interested in create those fortune files or how to use them with the Fortune Widget.

This entry was posted in Computing, HowTo, Linux, Wordpress and tagged , , , , , . Bookmark the permalink.

2 Responses to HowTo: Create Fortune Files

  1. Pingback: Get random vim tips using fortune. « a day in the life…

  2. Pingback: fortune with anarchist quotes « sindikat

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">