Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 03 FEB 2003 06:24:31PM Steve Smith wrote:

I fear I've missed the obvious answer to this…please excuse the following ramble…

Is there any technical reason why a server-side include wouldn't expand from a cgi-bin script?

Given a file called "some.txt" that contains a string

the quick brown dog

and a file called ssi.shtml in the same path as some.txt (server root), whose source is


This is above the insert



This is below the insert


You'd usually see ssi.shtml in a browser as

This is above the insert the quick brown dog This is below the insert

But when I render ssi.shtml from a cgi-bin script, it doesn't expand the insert and all I get is

This is above the insert This is below the insert

I suspect the differences in URL suffix (.shtml versus something else) are partly to blame.

I suspect

<!--

gets treated as a comment in one instance and an insert in another. Anyone care to venture the mechanism by which this eventuates (on a Microsoft IIS Web Server)?

Is there a simple trick to get a SSI (server side include) to expand from a cgi-bin script, or is it impossible?

Steve


At 04 FEB 2003 02:10AM Donald Bakke wrote:

Hi Steve,

I passed this on to our webmaster and here is his response:

I would like to see the actual code that he is trying to run and what platform and web server he is using. Lets say he is trying to call a SSI from a Perl script on a UNIX/Linux machine running an Apache web server:

- The default extension for calling SSI is .shtml. You can edit the servers directives file or the directives in the .htaccess located in the www root to allow you to call SSI from any extension other you wish. The directive tells the web server to parse any file with the other extension.

- Since the Perl interpreter does the parsing and sends the output directly to the browser the SSI embedded in your script is not parsed. To get around this, you can open the SSI file from Perl and assign the content to a scalar or send the contents send the contents directly to the browser, or whatever…

I hope this helps and let me know if you have any questions.

[email protected]

SRP Computer Solutions, Inc.


At 04 FEB 2003 03:54AM Steve Smith wrote:

Thanks, Don,

Effectively your Webmaster is saying that a cgi-bin script can imbed text by reading an "insert" file into a variable and rendering it in situ - this option is quite viable (as in the Perl script below - to show a different "thought for the day" file based on server date).

I just wondered if an insert was possible the .shtml way from within any other file suffix (notably cgi style scripts). I now suspect not.

Thanks for your efforts,

Steve

print "HTTP/1.0 200 OK\n";
print "Content-type:text/html\n\n";
# retrieve and dissect the system date string
($day, $month, $dayofmonth,$rest)=split(/\s+/,localtime(time),4);
($hour, $minute, $second, $rest)=split(/:/,$rest,4);
($second, $year )=split(/\s+/,$second);
# initialise a month variable
my ($mth);
$mth=$month;
# create a day of month 
$day=sprintf("%02d",$dayofmonth);

#output the standard heading for thought of the day
print "Message for Today" ;
print  'Message for Today

";

# $srcfile now contains the dated filename 
# as /mypath/mmdd.htm
# to recycle each message once a year on the same day.

$srcfile=mypath/";
$srcfile .= $mth;
$srcfile .= $day;
$srcfile .= ".htm";
# open $srcfile to read the text - this is a file with a message 
open(HANDLE, "$srcfile") || print "cannot open $srcfile";
while () 
{
     print "$_" ;
}
close(HANDLE);
# close the file and wrap up the HTML page
print '';
exit;

At 04 FEB 2003 11:12AM Donald Bakke wrote:

Steve,

Another response from our webmaster:

I misunderstood the question.

If the web server permissions allow it, you can execute scripts similar to calling an SSI using:

The output from the script will then be displayed on the page. I do this often. On www.desertvacationhomes.com the date in the top is generate from a Perl script.

Does this help?

[email protected]

SRP Computer Solutions, Inc.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/83c25b2c685b851085256cc200809692.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1