[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGI Error



Hi,

I tried to write a simple cgi program under Pi3, but there's something
wrong, please help me.

I use Turbo Pascal 7 to write this program (also tried to write a batch
file under 4dos, same result, it seems not a problem of pascal :-), it
worked and saved POST data in to a file CGI_TEST.TXT, but it does not
return, the client can't see the program output and will wait forever.
The following is source code:

program cgi_test;
uses dos;
type
    oar=array [1..65000] of char;
var
   f,g:file of char;
   buf:pointer;
   size,code,i:word;
begin
     val(getenv('CONTENT_LENGTH'),size,code);
     getmem(buf,size);
     assign(f,'');
     reset(f);
     assign(g,'CGI_TEST.TXT');
     rewrite(g);
     for i:=1 to size do
     begin
          read(f,oar(buf^)[i]);
          write(g,oar(buf^)[i]);
     end;
     close(f);
     close(g);
     writeln('Content-Type: text/html');
     writeln;
     write('<HTML><BODY>');
     write('<H1>Thank you for using CGI_TEST<BR>');
     write('Your information was send to the webmaster</H1>');
     writeln('</BODY></HTML>');
     halt(0);
end.


Tks.
Xiangrong Fang