BigNoseBird.Com- Home Small Logo
The 508 Compliant Guide to 
       Big Nose Bird
BACK

Running CGI Scripts and
Executing Programs From Your
Server Side Include Enabled Pages

One of the greatest things about using server side includes is the ability to either run programs as straight system executions, or as CGI Scripts. For security reasons, most servers are now configured to only use the Virtual method instead of the Exec method.

The primary differences between the two methods are:

  • Exec scripts do not inherit all that great CGI Server/Client information that Virtual does.

  • Virtual scripts must be in a directory from which you can run CGI scripts.
Personally, I strongly recommend that you employ the Virtual method. For purposes of completeness, both are presented here.

THE EXEC SSI

My sincerest apologies to my readers using non-graphical browsers for what follows next...
BigNoseBird.Com Says Today is Sep 24, 2017
   Sunday
   Monday
  Tuesday
Wednesday
 Thursday
   Friday
 Saturday
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

The calendar above was done using a small PERL program and what is called an exec cgi. We will be exploring this method soon, so stay tuned...

If you are really impatient then here is the idea... Take the line of code below and place it your HTML document where you want to place the calendar.

<!--#exec cmd="./calprog.cgi" -->

Now, download calprog.cgi and place in it the same directory that your HTML document is in. Make sure that the line:

#!/usr/bin/perl

Is the very first line in the script with no blank line above it!

After installing the script issue the command:

chmod 755 calprog.cgi

To test the program, at your prompt, enter the command:

./calprog.cgi

You should see a bunch of HTML code go by. If you only get the names of the days, check the program for the path to your Unix cal program. If it does not run at all, recheck your chmod 755 calprog.cgi and the path to perl in the program.

There are two potential problems. The first is that some systems require that executable programs for use with SSI reside in a special directory. The other is that they may have to end with the extension .cgi Some systems also forbid this type of program for security reasons. If so, please take a look at the next section which deals with calling cgi-bin programs using SSI.

If you cannot get this program to run, see if your system has a FAQ on where to place executables for use with SSI.


The INCLUDE VIRTUAL SSI
Many servers do not allow the EXEC SSI to be used. If this is the situation at your site, this is probably a good way around this restriction.

In our calprog.cgi example above, we are running a small program that returns HTML text back to the browser. Using the code below, it is possible to run the include from our CGI directory.

<!--#include virtual="/cgi-bin/calprog.cgi" -->
It is also very important to make a minor change to our program. Since we are using CGI, we must tell the browser what exactly is being returned to it. This is accomplished by starting our programs output with:
print "content-type: text/html\n\n"

The other major difference from the EXEC is that you give a URL such as:

/cgi-bin/calprog.cgi

Even better, you can pass information via the QUERY_STRING to your script like this:

/cgi-bin/calprog.cgi?name=joe&id=12385

This combination of SSI and CGI is ideal for applications such as banner rotation programs and counter scripts.

 



Find or Give Help on the BBS
 
Home Top E-Mail
If it looks great, it's by Christine
Some Fine Print
© 1997-2003 BigNoseBird.Com®, Inc. All rights reserved. All other trademarks are the sole property of their respective owners. The products that we recommend are only ones that we use. We have no relationship with any of the authors or their companies. We cannot assume responsibility for their ultimate performance or lack of same. We also cannot assume responsibility for either any programs provided here, or for any advice that is given since we have no control over what happens after our code or words leave this site. Always use prudent judgment in implementing any program- and always make a backup first! For further information, please read our Privacy Statement. We can be contacted at webmaster@bignosebird.com.


<reallybig.com>
Web Builder Network Portal
Advertise
on the
Reallybig.com
Network
BigNoseBird Newsletter
Subscribe
Un-Subscribe


Sign up today to receive our low volume newsletter. Tips, tricks, news, and whatever else crosses our minds.
Back Issues
Privacy Statement