shakazulu69
Feb 2nd, 2001, 02:07 PM
I'm trying to open a CGI script from a PerlScript page so that I can "wrap" the CGI and use PerlScript features such as retrieving cookies, etc. However, when I try to run the CGI (a *.exe) from within my PerlScript, I get a 502 CGI error. It works if the script is *.pl. Any ideas on whether this is even possible? Any help would be
appreciated.
The Perlscript file has the following:
<%
######
#
# the cgi called
#
######
my $CGI_CMD="\\inetpub\\scripts\\CGI_SCRIPT.EXE |";
######
#
# call the cgi, set all descriptors to binary mode
#
######
open(CGI_IN, $CGI_CMD) || failure ("Could not open $CGI_CMD");
binmode (CGI_IN);
binmode (STDOUT);
my $haveHTML = 0;
HEADERLINE: while (<CGI_IN>)
{
$Response->write( $_ );
last HEADERLINE if /^$/; # the header terminating blank line
last HEADERLINE if /^\r$/; # (which may contain a CR)
$haveHTML = 1 if m!text/html!;# check for mime type "text/html" }
######
#
# read HTML data line-wise
#
######
if ($haveHTML)
{
while (<CGI_IN>)
{
$Response->write( $_ );
}
}
######
#
# all other, non-HTML data, stream unchanged
#
######
else
{
while ( $cb = read(CGI_IN, $data, 1024) )
{
$Response->write( $data );
}
}
######
#
# close the cgi
#
######
close CGI_IN;
%>
Thanks,
Shamir
appreciated.
The Perlscript file has the following:
<%
######
#
# the cgi called
#
######
my $CGI_CMD="\\inetpub\\scripts\\CGI_SCRIPT.EXE |";
######
#
# call the cgi, set all descriptors to binary mode
#
######
open(CGI_IN, $CGI_CMD) || failure ("Could not open $CGI_CMD");
binmode (CGI_IN);
binmode (STDOUT);
my $haveHTML = 0;
HEADERLINE: while (<CGI_IN>)
{
$Response->write( $_ );
last HEADERLINE if /^$/; # the header terminating blank line
last HEADERLINE if /^\r$/; # (which may contain a CR)
$haveHTML = 1 if m!text/html!;# check for mime type "text/html" }
######
#
# read HTML data line-wise
#
######
if ($haveHTML)
{
while (<CGI_IN>)
{
$Response->write( $_ );
}
}
######
#
# all other, non-HTML data, stream unchanged
#
######
else
{
while ( $cb = read(CGI_IN, $data, 1024) )
{
$Response->write( $data );
}
}
######
#
# close the cgi
#
######
close CGI_IN;
%>
Thanks,
Shamir