Prolog.exe as CGI Script

From: Manfred Langhammer (384317480543-0001_at_T-Online.at)
Date: 06/12/04

  • Next message: Jean-Noël Mégoz: "How many man(X) ?"
    Date: Sat, 12 Jun 2004 17:46:25 +0200
    
    

    Hello,

    I try to call a Prolog exe from the CGI. I used exactly an example from the
    SWI-Prolog Homepage (http://www.swi-prolog.org/) that can be found in the
    documentation of the clib package:

    1) Created the following Prolog Source:
    :- use_module(library(cgi)).

    main :-
            cgi_get_form(Arguments),
            format('Content-type: text/html~n~n', []),
            format('<HTML>~n', []),
            format('<HEAD>~n', []),
            format('<TITLE>Simple SWI-Prolog CGI script</TITLE>~n', []),
            format('</HEAD>~n~n', []),
            format('<BODY>~n', []),
            format('<P>', []),
            print_args(Arguments),
            format('<BODY>~n</HTML>~n', []).

    print_args([]).
    print_args([A0|T]) :-
            A0 =.. [Name, Value],
            format('<B>~w</B>=<EM>~w</EM><BR>~n', [Name, Value]),
            print_args(T).

    2) Compiled this source to an exe file:
    % pl -o cgidemo --goal=main --toplevel=halt -c cgidemo.pl

    3) Put this cgidemo.exe to my cgi-bin directory of my apache server.
    4) Called it: http://localhost/cgi-bin/cgidemo.exe?hello=world

    The result is 500 - internal server error. In the apache error log I find
    the following entry:
    Premature end of script headers: cgidemo.exe

    I suppose that the prolog programm is not able to send the HTML-Output back
    to CGI, but I'm not sure. I followed exactly the steps documented in the
    clib package documentation and I have no idea what's going wrong. I searched
    the web and the SWI-Prolog Pages for hours without any success.

    Perhaps anybody could help me get started with that??

    Best regards
    Manfred Langhammer


  • Next message: Jean-Noël Mégoz: "How many man(X) ?"

    Relevant Pages

    • Re: PSP (was: Mainstreaming Prolog a Pragmatic Approach?)
      ... CGI is often a bit clumsy anyway, ... > The page is sent to a CGI program on the web server. ... > the Prolog interpreter starts up, then it loads up the Prolog program, ...
      (comp.lang.prolog)
    • Re: PSP (was: Mainstreaming Prolog a Pragmatic Approach?)
      ... >> without having to exit and restart all the time. ... >> to keep the Prolog interpreter open, handling CGI calls? ... The most sensible solution is to have a Prolog ... > system acting as a server that stays alive ...
      (comp.lang.prolog)
    • Re: PSP (was: Mainstreaming Prolog a Pragmatic Approach?)
      ... >> I've discovered that CGI and Prolog just don't work together. ... The way CGI works is like this. ... The page is sent to a CGI program on the web server. ... If the program which is on the webs sever is a Prolog program, ...
      (comp.lang.prolog)
    • Re: ANN: Prolog Server Pages
      ... I've been working on a Prolog Server Pages (PSP) implementation. ... > The whole system is based on SWI-Prolog and CGI, so it can be run on any web ...
      (comp.lang.prolog)
    • Re: Prolog.exe as CGI Script
      ... "complicated" Prolog code with ODBC connection to a MySQL Database. ... include the prolog bin directory in the path variable as I found out that I ... Finally I placed my prolog exe in the cgi-bin directory of apache and it ...
      (comp.lang.prolog)