At 10:31 AM +0100 5/6/02, Ian Cass wrote:
> > What you've got there is prob what I'd do for getting it to run...
>
>It's nice to know I'm not missing something completely obvious.
See some comments below
> > although I'd probably add a parameter to the cgi script so it skipped the
>content-type stuff (thereby stopping you from having to strip it)
>
>True, but I wanted a generic fits-all solution without having to maintain
>modified versions of CGI source.
I'm not sure what you mean by "fits all" solution. If you add a flag
like "--no-headers-footers" or "--includable" then the CGI program
should just skip sending out content-type and <html></html> tags. No
big deal.
> > Could you make the functions in the cgi script (presuming it is perl) in
>the global.asa and then just run the funcs?
>
>The CGI's I've got in mind are written in c++.
I recall that the `backtick` approach to run another program in perl
is ok but means all output gets buffered therefore more memory etc.
Probably these days it doesn't make much difference, but I tried a
different approach just to see if it would work.
The following works nicely:
#!/usr/bin/perl
# note 1: use of sh style variable setting on command line
# (presumably perl just forks a sh? Eh, it works.
# note 2: use of flag to blah.cgi to tell it to skip content-type stuff
# If flag can be added then see Note 3.
$streamName = "QUERY_STRING=\"$ENV{QUERY_STRING}\" ./blah.cgi --no-header-foote
r |";
open( STREAM, $streamName ) or die "Uh-oh, couldn't open the stream";
LINE: while ( defined( $line = <STREAM> ))
{
# Note 3: skip these checks if can request no headers/footers
next LINE if $line =~ /^Content-type:/;
next LINE if $line =~ /<html/i;
next LINE if $line =~ /<\/html/i;
print $line;
}
It is more verbose, but (arguably!) cleaner and probably more
efficient as the output is printed as it is read.
HTH
Ellers
>--
>Ian Cass
>
>
>>
>> HTH
>>
>> Ellers
>>
>>
>> 6/5/02 4:36:25 PM, "Ian Cass" <[EMAIL PROTECTED]> wrote:
>>
>> >Hi,
>> >
>> >Bit of a puzzler here. What would be the correct way of running a CGI and
>> >have its output embedded on an Apache::ASP page?
>> >
>> >The site I'm working on has no frames & uses headers and footers to
>provide
>> >formatting. What I want to be able to do is to print my headers, the
>output
>> >from the generic CGI, then print my footer. Obviously, a redirect wont
>work
>> >here & an include will not execute the cgi. I need an 'exec and include
>> >output' command.
>> >
>> >I've come up with a horrible .asp wrapper hack for now that works for me,
>> >but I'm convinced there must be a 'proper' way of doing this.
>> >
>> >#!/usr/local/bin/perl asp
>> ><%
>> >$Response->Include($Server->MapPath("/gui/header.inc"));
>> >my $me = basename($0);
>> >$me =~ s/\.asp//;
>> >my $content = `env "$ENV{'QUERY_STRING'}" ./$me.cgi`;
>> >$content =~ s/Content-type:.*\n//;
>> >$content =~ s/<html>//;
>> >$content =~ s/<\/html>//;
>> >$content =~ s/<body[^>]*>//;
>> >$content =~ s/<\/body>//;
>> >print $content;
>> >$Response->Include($Server->MapPath("/gui/footer.inc"));
>> > %>
>> >
>> >--
>> >Ian Cass
>> >
>> >
>> >
>> >
>> >---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>> >
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]