Re: Problem with compile_predicates/1 under SWI
- From: "Benjamin Johnston" <superhero@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Jul 2005 10:11:10 +1000
I am using IIS 5.1;
I set up an application mapping for .pl files as follows:
"c:\program files\pl\bin\plcon" -g go -t halt -q -s "%s"
Then I created a test.pl file:
p(a).
go :- compile_predicates([p/1]), write('Content-type: text/html\r\n\r\n'),
write(hi), flush_output.
When I ran it, it worked perfectly for me.
Some things to consider/try:
If you don't output much data, you may need to flush_output to ensure that
the headers are returned.
Make sure that plcon has a -q parameter so it doesn't show the "% sample.pl
compiled" message
If you consult other files, make sure that you consult them silently:
load_files([File],[silent(true)]).
Finally, I noticed that if I make a HTTP request to another site using SWI
Prolog, then SWI Prolog (well, version 5.4.5) will output an irrelevant "|:"
prompt on STDOUT (but not expect input). If it happened, I fixed it by
making my headers this:
write('Foo: bar\r\nContent-type: text/html\r\n\r\n')
this will add an irrelevant header if the |: prompt doesn't appear, and will
make your headers valid if the |: prompt does appear (you'll end up with a
header with key "|" and value ":Foo: bar").
-Benjamin Johnston
> Ye, I saw it...u r right. But my puzzle remains unsolved.
> I tried this simple script:
>
> p(a).
> go :- compile_predicates([p/1]), write('Content-type: text/html\r\n\r\n'),
> ...
>
> and it works on Apache server.
> Perhaps it is a problem of IIS6.0, the server I'm using for developing my
> app.
> Incredible!
> Thx
> M
>
> "Jan Wielemaker" <jan@xxxxxxxxxxxx> ha scritto nel messaggio
> news:slrnddaq90.9l5.jan@xxxxxxxxxxxxxxx
>> On 2005-07-13, Mauro Di Nuzzo <picorna@xxxxxxxxx> wrote:
>> > Hi all!
>> >
>> > I am running a prolog program as a CGI script.
>> > If I try to call compile_predicates/1 before sending http headers, I
> receive
>> > a server error message (telling me it received bad http headers).
>> > Since I have to call that predicate before sending http headers, the
> problem
>> > is evident.
>> > Does compile_predicates/1 outputs something? I do not see any "visible"
>> > output, but the server does not agree with me.
>> > Please help me.
>>
>> A quick scan through the source suggests it does not produce any textual
>> output unless an error is detected.
>>
>> Cheers --- Jan
>
>
.
- Follow-Ups:
- Re: Problem with compile_predicates/1 under SWI
- From: Jan Wielemaker
- Re: Problem with compile_predicates/1 under SWI
- References:
- Problem with compile_predicates/1 under SWI
- From: Mauro Di Nuzzo
- Re: Problem with compile_predicates/1 under SWI
- From: Jan Wielemaker
- Re: Problem with compile_predicates/1 under SWI
- From: Mauro Di Nuzzo
- Problem with compile_predicates/1 under SWI
- Prev by Date: Re: Newbie: Translate natural language statements into logic
- Next by Date: Re: Problem with compile_predicates/1 under SWI
- Previous by thread: Re: Problem with compile_predicates/1 under SWI
- Next by thread: Re: Problem with compile_predicates/1 under SWI
- Index(es):
Relevant Pages
|