Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Random Quotes? Bah, hook into /usr/games/fortune!
  • Posted: 22.04.2003, 21:33
     
    ochiba
    rank:
    Freshman Freshman
    registered:
     September 2002
    Status:
    offline
    last visit:
    06.01.04
    Posts:
    40
    I toyed around with the stock random quotes block, but I couldn't really justify typing all those buggars in by hand. So I thought, "Hmm, why not hook into fortune and use all those gems?"

    Here's how...

    Create a new Core/PHP block, call it what you want and position it wherever you want. The contents of that block should be as follows:

    Code

    echo "<br><i>\n";
    $fortune = shell_exec ("/usr/games/fortune -ae");
    echo(nl2br($fortune));
    echo "</i>\n";


    This should output a randomly selected quote from the popular fortune program. It should work as-is on most RedHat systems, but may need to be modified based on your particular system build.

    It's not much, but I liked it.

    --
    Joshua D. Hensley
    Network Engineer, Unisys
    USCG Operations Systems Center
    http://www.webflux.net
  • Posted: 28.04.2003, 11:10
     
    jsandfort
    rank:
    Freshman Freshman
    registered:
     April 2003
    Status:
    offline
    last visit:
    16.10.05
    Posts:
    11
    Nice. Now if it could only output Dubya quotes...

    :twisted:
  • Posted: 28.04.2003, 17:28
     
    ochiba
    rank:
    Freshman Freshman
    registered:
     September 2002
    Status:
    offline
    last visit:
    06.01.04
    Posts:
    40
    Dubya, you say?

    If you have a list of favorite qutoes, edit a plain text file with vi (or your favorite alternative) and add all the Dubya quotes you can handle. Separate quotes with a % sign on a blank line between each quote, and then run

    Code

    strfile <plain text quote file name> <samename.dat>


    to output a file formatted for reading by fortune. Copy that file to /usr/share/games/fortune with the rest of your fortune files, and you should then be able to run "fortune <yourfile>" and get a random quote from it.

    --
    Joshua D. Hensley
    Network Engineer, Unisys
    USCG Operations Systems Center
    http://www.webflux.net</yourfile>
  • Posted: 28.04.2003, 21:18
     
    jsandfort
    rank:
    Freshman Freshman
    registered:
     April 2003
    Status:
    offline
    last visit:
    16.10.05
    Posts:
    11
    Haha. Thanks. :D
  • Posted: 27.05.2003, 17:07
     
    MasterC
    rank:
    Freshman Freshman
    registered:
     May 2003
    Status:
    offline
    last visit:
    02.12.03
    Posts:
    8
    Thanks!
    I just figured I'd chime in to tell you thank you, I ran across this on several occasions and have used it each time.

    Cool

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula