in reply to Append script output to complex block of html and script

Perhaps you could supply some code to make the problem a little more clear.

With out knowing more, I'll take a stab in the dark and suggest a serverside include in the client's pages of your script.

Good luck and give us some more details so we can help...

-monkfish

  • Comment on Re: Append script output to complex block of html and script

Replies are listed 'Best First'.
Re: Re: Append script output to complex block of html and script
by jerrygarciuh (Curate) on Sep 07, 2001 at 07:47 UTC
    Well, the jist of it is that the script currently spits out a whole page which it writes from scratch. I need to alter the script so it opens a file of 30 lines of html and appends the script output onto it. Like a search engine does, the logo is there, the links are there, and my on-the-fly code sits underneath. I don't expect anyone to write this I just can't seem to find an answer in my books. I am clearly not asking this in a way which makes perlsense.
      The code below does as you ask. It opens an existing html file, prints it and then runs your script.

      use strict; use warnings; open(FH,"<./test.html") || die "couldn't open file $!\n"; my @html=<FH>; close(FH); print @html; print " my script stuff<P>\n"; print '</body>';
      As monkfish suggests a server side include may also do what you want.

      You would put the following line inside your html document

      <!--#exec cgi="/cgi-bin/yourscript.pl" -->

      Some random personal SSI thoughts:

      1. Microsoft IIS is more forgiving of syntax sloppiness. For example you can have a space between the -- and the # This can cause problems when you switch to apache.

      2. Your server has to have SSI enabled and has to allow exec commands. Allowing any user to execute any command in their page is considered a security risk.

      3. As far as I know, there is not a portable way to pass your CGI parameters. Apache supports environment variables. IIS supports a parameter string but not vice versa

      Hope this helps


      --mandog

        Apache supports a parameter string as well, you just have to pass it to the html file itself like this:

        somefile.shtml?param=somevalue¶m2=somevalue ...

        As an answer to the original question... I believe SSI is the way to go. From what I understand you'll just need to remove the beginning tags from the script you create. Another way to do it would be to use HTML::Template (availiable from CPAN). I often mix both HTML::Template and SSI to do the very same thing you are doing but not have any HTML code inside the script itself.

        Thanks mandog! The script works great! Will now attempt to weave it into my return_html subroutine. Yeehaa! jg