I am using server side includes on all my static pages but I would like a way to bring this info in on a cgi page.
The code I use is
<!--#include virtual="/cgi-bin/sample.cgi" -->
Works great for static pages the problem is when I use this on a dynamic page.
What would I use to bring in sample.cgi on a dynamic page?
You can go around this by writing your own function to do the trick.
I use templates for my CGIs. All the HTML is stored separately. So what I do is, I request the page from the server with CGI script and then parse and substitute all the variables in it after.
You can do similar, just request the page from your own server and then display HTML.
Take a look at LWP module.
[edited by: moltar at 3:35 am (utc) on Aug. 4, 2003]
Just one last thing. What if sample.cgi is just one small element in a page. You would have to program this code into the rest of the dynamic page with all the other elements?
Say sample.cgi is just a navbar from another program you want to insert into a dynamic page that already has coding for the Header Body Footer etc.
Thanks
That is what I do right now. I did a little research and unfortunately couldn't find anything better.
I don't understand why wouldn't Apache let SSI work from dynamic pages. What stops it? Anyone?
I don't understand why wouldn't Apache let SSI work from dynamic pages. What stops it? Anyone?
It's just a setting in the Apache configuration that determines what file extension(s) will get passed through the SSI engine. So it could be done, by why would you want to on a CGI page when you could just use the CGI language itself to do it?
It's just a setting in the Apache configuration that determines what file extension(s) will get passed through the SSI engine. So it could be done, by why would you want to on a CGI page when you could just use the CGI language itself to do it?
Well I want to bring in a small script into a different cgi program. So I was looking at a easy way of doing this without writing more code. I am not that experienced at coding...
[perl]
# fill in full local path to file
my $navigation = &SSI_INCLUDE("/home/html/navigation.html");
sub SSI_INCLUDE {
my ($file) = @_;
undef $/;
open(FILE, $file);
flock(FILE, 2);
my $content = <FILE>;
flock(FILE, 8);
close($file);
$/ = "\n";
return $content;
}
[/perl]
You would put $navigation in your cgi script's output wherever you want the navigation menu to appear. I don't know why there might be any problems with including files in scripts .. I use the above often and specifically for things like navigation menu's ... but use at your own risk.
Maybe you can change the two scripts to share files with the relevant subroutines so that you can use the output of one sub routine in multiple scripts.
Luckily I can still contribute something really useful :) :
You get the nice colors by typing
[ perl ] and [ /perl ]
(without the spaces) around your perl fragment.