From jan@swi.psy.uva.nl Wed Jul 11 20:14:45 2001 Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30]) by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f6BIEjX26237; Wed, 11 Jul 2001 20:14:45 +0200 (MET DST) Received: from localhost (localhost [[UNIX: localhost]]) by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f6BIEjH32682; Wed, 11 Jul 2001 20:14:45 +0200 From: Jan Wielemaker Organization: SWI, University of Amsterdam To: Jacobo Myerston , prolog@swi.psy.uva.nl Subject: Re: [SWIPL] HELP-Calling prolog from CGI scripts Date: Wed, 11 Jul 2001 20:09:56 +0200 X-Mailer: KMail [version 1.0.29.2] Content-Type: text/plain References: <200107111102.f6BB2uf28820@gollem.swi.psy.uva.nl> In-Reply-To: MIME-Version: 1.0 Message-Id: <01071120144501.32516@gollem> Content-Transfer-Encoding: 8bit On Wed, 11 Jul 2001, Jacobo Myerston wrote: >I've inserted the line: > >> >>#!/usr/local/bin/pl -q -g main -s > >in cgidemo.pl > >>but, I got only three characters in the browser: 1 ?- cgidemo.pl was written well before 4.0.5. I've updated it a bit, and the following behaves nicely on the query http:///cgi-bin/cgidemp.pl?hello=world =================================================================== #!/usr/bin/pl -q -g main -s /* $Id: cgidemo.pl,v 1.3 2001/07/11 18:09:43 jan Exp $ Part of SWI-Prolog Designed and implemented by Jan Wielemaker Copyright (C) 1999 SWI, University of Amseterdam. All rights reserved. */ :- use_module(library(cgi)). main :- cgi_get_form(Arguments), format('Content-type: text/html~n~n', []), format('~n', []), format('~n', []), format('Simple SWI-Prolog CGI script output~n', []), format('~n~n', []), format('~n', []), format('

Form arguments

'), format('

', []), print_args(Arguments), format('~n~n', []), halt. print_args([]). print_args([A0|T]) :- A0 =.. [Name, Value], format('~w=~w
~n', [Name, Value]), print_args(T). ===================================================================== To install it under Unix, simply put this as an executable file in the CGI-Bin directory. Make sure the path after #! is correct. Note the call to halt/0 to make the CGI script end. --- Jan