How to use Random Numbers on Your Home Page

You can come up with a lot of fun things to do with random numbers on your page. Sometimes the best joke is just to put a random number in an innocent looking place, and wait for people to wonder why it's different each time they visit!

Installing the random number generator is similar to installing the counter. But this time, you'll have to copy the random number program to your directory, edit it, and then make your .shtml file call it. Here are the steps:

  1. Move into the directory with the page you want to add a random number to.
  2. Copy the random number program into your directory using this command:
    	  cp /user/mpg/public_html/cgi-bin/random.perl .
            
    Make sure you include the final period and separate it from the word 'perl' by a space!
  3. Make sure the permissions on the file are set properly so that the WWW server can run it. Type:
    	  chmod 755 random.perl
            
  4. Edit the file random.perl with your favorite text editor. Find the line that says $uppervalue = 99; and change 99 to the upper bound that you want the random number to have. Remember to save the file when you're done!
  5. Make sure the name of the document you want the random number to be in has a name ending in .shtml
  6. Go to the place in your document where you want the number to appear, and insert this line:
    <!--#exec cgi="random.perl"-->

Each time someone retrieves your document, the program will replace that line with a random number. It's simple! Here's what the random number generator will do:


Fortune Cookie Lucky Number is [an error occurred while processing this directive]

Back to Making Your Home Page Cooler