Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2000
    Posts
    542

    Enable SSI for cgi-scripts...

    How can I do so?

  2. #2
    Join Date
    Dec 2000
    Location
    Miami, Florida
    Posts
    100
    I don't think that's possible. However there is a way. And I use it for my estimate script (http://www.dim8.net/cgi-bin/estimate.pl).

    All I do is where I want a txt file to be inserted, I use this code:

    open(INF,"menu.txt") or dienice("Can't open menu.txt: $!");
    @ary = <INF>;
    close(INF);

    foreach $line (@ary) {
    chomp($line);
    print "$line";
    }


    And it adds the menu.txt file right where I want it. =0
    Robert C. Rodriguez
    Dimension 8 WebHosting - http://www.dim8.net
    Hosting For The New Dimension!
    robert@dim8.net

  3. #3
    Join Date
    May 2001
    Location
    West Lafayette, IN
    Posts
    22
    Ditto, its not possible (at least I am fairly certain). You could write or find a SSI parser for perl/python/[insert your favorite scripting language here] instead.
    Regardless, why would you want to use SSI when you are using a CGI script? Its just easier to let the script take care of that stuff instead...
    - Matt Wirges
    http://www.sharpwebinnovations.com/
    sysadmin@sharpwebinnovations.com
    Nil novi sub solo.

  4. #4
    Join Date
    Dec 2000
    Posts
    1,280
    The above code is good, but here's an even better one..
    put this code at the end of your CGI script.


    Code:
    sub rFile {
      if(-f $_[0]) {
        open(FILE, $_[0]) || die "Could not open $_[0] : $!";
          while(<FILE>) {
             print $_;
          }
        close(FILE);
      } else {
        die "$_[0] does not exist";
      }
    }
    Now during your script you can call this subroutine as many times as you want by simply adding the following to your script (where ever you want the SSI replacement):

    Code:
    &rFile("dir/file.txt");
    Simply replace "dir/file.txt" with the path and filename of your file. Keep in mind that this script also makes sure that the file exists prior to opening it.

    Saeed
    (SH)Saeed

  5. #5
    Join Date
    Dec 2000
    Location
    Miami, Florida
    Posts
    100
    Yeep.. that code is much better. It's much easier for me to add only 1 line of coding to have a file inserted than using that code. Thanks for the code.. I've changed my scripts to start using that code! =0
    Robert C. Rodriguez
    Dimension 8 WebHosting - http://www.dim8.net
    Hosting For The New Dimension!
    robert@dim8.net

  6. #6
    Join Date
    Dec 2000
    Posts
    1,280
    I'm glad I could help, feel free to email me if you need other programming/database work done.
    (SH)Saeed

  7. #7
    Join Date
    Dec 2000
    Posts
    542
    Thanks pal. Actually my client asked for it. I don' t know he want to use it, but it's just not my business.

  8. #8
    Join Date
    Jul 2000
    Location
    Switzerland
    Posts
    100
    With Apache 2 it is possible, but it is still beta.
    Apache modules may now be written as filters which act on the stream of content as it is delivered to or from the server. This allows, for example, the output of CGI scripts to be parsed for Server Side Include directive by mod_include.
    - domi
    [ voodooweb hosting ]
    hosting@voodooweb.com
    Internet Solutions made in Switzerland

  9. #9
    Join Date
    Apr 2001
    Location
    FL, USA
    Posts
    949

    FastTemplate.pm

    Check into a Perl Module called FastTemplate.pm. This module is an OO perl module that can parse HTML template files with variable subsitutions. This may need more than what they need, but FastTemplate.pm is a nice way to seperate your HTML code from the perl code. If you don't need any variable interpolations, then use one of the methods above.

    We save you time, money, and frustration by handling the server management tasks required to run an online business successfully.
    No prodding required. We just do it right the first time. Red Hat, MySQL, Plesk, and cPanel certified staff.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •