Knowledge Base

Authoring/Development - System CGI: random_text


Modifications Required:

Yes is a script that takes text you specify and randomly displays it on your Web site. It must be copied to your own Web directory and modified for your own use.

You will normally want to place in a CGI directory, although this is not strictly required (because it has the .pl extension, it will execute as CGI from any directory).

To begin, copy the script into your Web directory. Use this sequence of commands when logged in by SSH:

cd ~/public_html
cp /usr/www/cgi-bin/ cgi-bin/.
Next, use your favorite text editor to modify the script. You will need to set two variables within the script:


This is the path to your text file (for example, /usr/www/users/USERNAME/example.txt).

This is what delimits the text in the file. For example, if you were putting quotations on your site, this is how the program will know when one quotation stops and another starts. The default is set to "%%\n", which means that in your text file you'll need to put a line between each quotation with two percents, like this:

"Something interesting"
- Some Guy
"Another saying"
- Someone else

To display the quotations on your site, include this code in your HTML wherever you want them to appear:

<!--#exec cgi="/cgi-bin/" -->
Since this is SSI, you'll need to make sure your HTML filename ends in .shtml, not .html. For more information, please see our article on SSI.

Shortcut To This Article:

Related Information