HP3000-L Archives

April 2000, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Mark Bixby <[log in to unmask]>
Date:
Thu, 20 Apr 2000 13:46:06 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (73 lines)
Hi Ken,

"Born, Ken" wrote:
>
> Hi gang,
> Starting out using APACHE and want to execute a PASCAL program using CGI.
> I keep getting the same error message over and over..."Premature end of
> script headers".  My PASCAL program is as follows:
> $TITLE 'Test Web Messages - Version 02.03'$
> $OS 'MPE/XL'$
> $NOTES OFF$
> $HEAP_DISPOSE ON$
> $HEAP_COMPACT ON$
>
> PROGRAM car_messages(output);
>
> VAR
>   i_text : char;
>   o_text : char;
> BEGIN
>
> WRITELN('THIS IS A TEST');

As others have already mentioned on HP3000-L, you need more than this.   You
need to write the HTTP headers before you write the content.

For example, my sample Pascal CGI is:

program pasccgi(output);

const
  nl=chr(10);

begin

writeln('Content-Type: text/html',nl,nl);
writeln('<html><body><h1>Hello World!</h1></body></html>');

end.

The use of the nl character is a workaround to some MPE shortcomings when MPE
programs send their output into POSIX pipes (which are read by Apache to get
the CGI content).

Each HTTP header must be terminated with an nl, and the end of the headers is
marked by an nl by itself.  Content then follows.

> I compiled the programmed on MPE and it runs fine.  However, when I transfer
> it to the cgi-bin directory and use a browser to execute it, I recevied the
> Boo Boo message.  This is the first time I am working with Apache and CGI's.
> Where can I look at samples regarding what is needed in the HTML document
> and what is needed in the MPE executable?

Additionally, older versions of MPE without current patches had trouble when
MPE programs written in 3GLs like Pascal or COBOL would try to re-open $STDIN
and $STDLIST (Pascal input and output files) while those files had been
redirected to POSIX pipes as is the case in the Apache CGI environment.

To see if this is your problem, perform the following test on your CGI:

        echo foobar | mycgiprog | cat -

This causes mycgiprog's $STDIN to be redirected to the piped echo output, and
the $STDLIST is redirected to pipe its output to the cat command.  You will see
nasty error messages if you have this problem.  The solution is to get current
on patches.

Or as Stan prefers, you can call the PRINT() and READ() intrinsics directly to
do your CGI I/O, and because no re-open is involved, you won't hit this
problem.

- Mark B.

ATOM RSS1 RSS2