Subject: Re: [clisp-list] read-byte and *standard-input*

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Thu May 15 00:34:01 2003

Thibault Langlois wrote:
>There is still something I do not understand:

>exotica$ test.cgi < /tmp/data.bz2
>(66 90 104 57 49 65 89 38 83 89) 

>But when the script is run by httpd it give the same error 
>again (from /var/log/httpd/error_log):
>*** - (SETF STREAM-ELEMENT-TYPE) on #<IO TERMINAL-STREAM> is illegal
>[Wed May 14 17:51:21 2003] [error] [client 194.117.35.226] 
>Premature end
>of script headers: /home/tl/www_public/test.cgi
>
>What is wrong ?

I'm sorry that you spent more time on this. What you miss is that current CLISP will only produce a setf-able *standard-input* if it is connected to a regular file. This is the case in your </tmp/data example. This is not the case in a cgi setting, were stdin/out are (presumably) pipes.

You need either
o my hack (or a later change of that into a regular command line option) so that CLISP will produce this kind of file/pipe/handle *standard-input/output* streams even when connected to pipes.

o or a wrapper around your script that will write all stdinput from the web-server to a file, and feed that file to CLISP. This will only work for one-invocation-per-access cgi however, CLISP cannot handle multiple requests with such a setting.
I'm not sure this works at all because httpd may not flush the input side of the pipe so that the wrapper sees an EOF and knows that it got all input.
You cannot write such a wrapper in CLISP itself, since you need faithful input.
Please try investigating around
#! /bin/sh
# My CGI wrapper
cat >/tmp/foo$$
#syslog "got all input"
clisp < /tmp/foo$$

Regards,
	Jorg Hohle.

---

From: Thibault Langlois <[email-masked]>
Date: Thu May 15 04:12:13 2003

> o my hack (or a later change of that into a regular command line option) so that CLISP will produce this kind of file/pipe/handle *standard-input/output* streams even when connected to pipes.

That is what I did yesterday at night. I was desperate to solve this
problem and I recompiled clisp with your patch. It works fine now !

I think this is a valuable feature. I wonder why this issue has not
arise sooner, clisp is the cl implementation that is the most suitable
to do cgi programming.  

I have ~100 students that, with your help, will be able to send their
homework through a form. At the beginning of the semestrer I asked them
to send ascii files but now, they have several files to send and it is
more convenient to use one zip archive. 
 
Thanks again.

Thibault

-- 
Thibault Langlois <[email-masked]>
FCUL / DI

---

From: Sam Steingold <[email-masked]>
Date: Thu May 15 11:15:02 2003

> * In message <1052997092.29631.10.camel@wok>
> * On the subject of "Re: read-byte and *standard-input*"
> * Sent on 15 May 2003 12:11:34 +0100
> * Honorable Thibault Langlois <[email-masked]> writes:
>

I just added a new function EXT:MAKE-STREAM which should simplify your
life a bit.
Please try CVS head and read the doc
<http://cvs2.cons.org/ftp-area/clisp/snapshots/impnotes.html#make-stream>
<http://cvs2.cons.org/ftp-area/clisp/snapshots/impnotes.html#bin-stdio>

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat9 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
A poet who reads his verse in public may have other nasty habits.

---

From: Thibault Langlois <[email-masked]>
Date: Thu May 15 16:34:04 2003

> <http://cvs2.cons.org/ftp-area/clisp/snapshots/impnotes.html#bin-stdio>

I have not tried yet but from the documentation it looks fine.
CLISP has a new useful feature !