Page 2 of 2

Re: Clozure Lisp CGI Programming

Posted: Tue May 12, 2009 4:13 am
by dmitry_vk
To check that you have permission issuses or not, you can run ccl under the www-data user:

Code: Select all

sudo -u www-data /path/to/index.cgi

Re: Clozure Lisp CGI Programming

Posted: Thu May 14, 2009 1:29 am
by Hero Doug
To the most recent reply, here are the results of running the app as www-data, it seems as if it's not a permission problem.
doug@doug-desktop:~/software/ccl$ sudo -u www-data /home/doug/dev/trunk/htdocs/index.cgi
[sudo] password for doug:
Content-type: text/html

This is a test
cgsullivan >> The "blank" in the error message you spoke of is filled in if I try to run it "like an interperted script".

Code: Select all

#!/home/doug/software/ccl/ccl -I /home/doug/dev/trunk/htdocs/image[/quote]

The error looks like this:
[quote]
Couldn't load lisp heap image from /home/doug/dev/trunk/htdocs/image
[Fri May 08 10:51:21 2009] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
[/quote]

You're indeed right, the two paths are not the same.
[quote]
[i]Terminal[/i]
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

[i]Apache[/i]
/usr/local/bin:/usr/bin:/bin
[/quote]

However, the executable should be self contained since I prepended the kernel, I'm not seeing why it needs a path at all. 

Anyways, I added the path to apache as you suggested and still had no luck.

I'm going to try saving it without prepending the kernel, maybe I'll be able to load the image by passing it to the CCL binary.



Wodin >> I get how the permissions work; running it as Opera was a brainfart indeed. And I downloaded SBCL from the site, not the repo. I've been using it and it works fine.

I shot an email off to the CCL dev list, I'll see if they can add anything to this.

Re: Clozure Lisp CGI Programming

Posted: Thu May 14, 2009 2:12 am
by John McAleely
I note that the error message does not appear to contain the .cgi extension.

What happens if you rename your executable to simply 'image', rather than 'image.cgi'? Perhaps CCL is trying to be a bit clever with an extension it doesn't expect.

Re: Clozure Lisp CGI Programming

Posted: Thu May 14, 2009 2:56 am
by Hero Doug
Ok, I got it working, sort of.

I make an image file and ran it under www-data using a shell script.

Code: Select all

#!/bin/sh

/home/doug/software/ccl/ccl -I /home/doug/dev/trunk/htdocs/sitewire.app
I also prepended the image file to the image and ran that as well using the same method.

Code: Select all

#!/bin/sh

/home/doug/dev/trunk/htdocs/index.cgi
This seems to have fixed the problem, although I never did find out why I had that other problem. At least i can get to work now.

Re: Clozure Lisp CGI Programming

Posted: Fri May 15, 2009 2:43 am
by Hero Doug
Now I have the same problems (and more) on my personal computer (I did all that other stuff from my work computer).

I can't save an image with a prepended kernel, and I cant run the image using ANY method.

I've shot an email off the the CCL guys and I'll see what they have to say. I have to say, I'm nearing my wits end.

Re: Clozure Lisp CGI Programming

Posted: Sat May 16, 2009 5:49 pm
by Hero Doug
I received an error when trying to save an image with a prepended kernel not long ago. I sent an Email to the Clozure mailing list and it was resolved surprisingly quickly.

[quote=The Error]
:The Error

> Error: value NIL is not of the expected type REAL.
> While executing: CCL::<-2, in process Initial(0).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 >
[/quote]

[quote=The Solution]
Supply the full path to the kernel
(save-application "whatever" :prepend-kernel "/full/path/to/kernel")
[/quote]

Re: Clozure Lisp CGI Programming

Posted: Mon May 18, 2009 8:42 am
by hrapof
Funny thing: I'm doing the same right now! CGI isn't very "cool" today, and Lisp isn't supposed to be particularly suited for CGI due to long startup time, and yet there are two persons simultaneously making CGIs with CCL :)
My Clozure CGI works fine with Apache on Windows XP, but fails miserably with IIS (due to some error in CCL-DIRECTORY or USER-HOMEDIR-PATHNAME).
Debugging it, I've noticed that if I call my CCL cgi from C CGI via EXECL, it fails, and SBCL doesn't. The reason is CCL is trying to load its core from the wrong place:

image_name = argv[1];
argv[1] = NULL;
} else {
process_options(argc,argv);
}
initial_stack_size = ensure_stack_limit(initial_stack_size);
if (image_name == NULL) {
if (check_for_embedded_image(argv[0])) {
image_name = argv[0];
} else {
image_name = default_image_name(argv[0]);

But if I use SYSTEM or POPEN, CCL works. So personally I think it's best to call it with a script - start up time shouldn't matter much, if we use Lisp for CGIs, after all ;)

Re: Clozure Lisp CGI Programming

Posted: Mon May 18, 2009 12:40 pm
by gugamilare
hrapof wrote:Funny thing: I'm doing the same right now! CGI isn't very "cool" today, and Lisp isn't supposed to be particularly suited for CGI due to long startup time, and yet there are two persons simultaneously making CGIs with CCL :)
If you save your lisp image, startup time (with no init file, of course) is very short.

Re: Clozure Lisp CGI Programming

Posted: Fri Jul 17, 2009 6:56 pm
by rme
hrapof wrote: My Clozure CGI works fine with Apache on Windows XP, but fails miserably with IIS (due to some error in CCL-DIRECTORY or USER-HOMEDIR-PATHNAME).
Some changes to CCL were checked into the trunk several weeks ago to try to address this.

If you're willing, please review http://trac.clozure.com/openmcl/ticket/517 and see if a current trunk still has problems.

Re: Clozure Lisp CGI Programming

Posted: Wed Jul 22, 2009 1:22 am
by szergling
I'm very late to post, so this is probably all over, but I've seen the "Premature end of script headers" error before programming cgi in clisp, usually because there's a problem somewhere in the #! line (wrong path to lisp, wrong init options, or any other error). Hope this helps...