There definitely seems to be a limit on stdin, at least with J504 on Red
Hat 8. I'll test it on Fedora when I get home.
Here are two test scripts:
echo.ijs: just counts stdin
---------
s=:stdin''
echo #s
blanks.ijs: generates n blanks separated by newlines
-----------
blanks=:3 : 0
for_i. i. n do. echo ' ' end.
)
n=:". 2{::ARGV
blanks n
exit''
jconsole blanks.ijs 250000 | jconsole echo.ijs ----> runs OK
However the following throws you back to the J interpreter:
jconsole blanks.ijs 375000 | jconsole echo.ijs
Presumably binary search would determine the buffer size.
If the files are not this big, perhaps there are a couple of other things
for Lorin to try.
1. Is the POST data terminated by a newline? If not, this is a source of
problems in other languages.
2. Is the process supplying data to stdin complete? A simple experiment
shows that J will only process stdin data after the source terminates.
Best wishes,
John
Joey K Tuttle wrote:
> I had a similar experience - an error (I forget the
> details) when trying to process stdin via a CGI call
> from a form where the client was uploading a file.
>
> Since there are other buffer issues in j !# shells
> (e.g. the one limiting the number of arguments, which
> Eric has promised to provide relief for in 6.01 - a
> reason I'm disappointed not to be able to test it
> in Linux until I upgrade my Redhat 8.0 system...)
> I decided that I would just do a workaround for my
> particular problem. The HTML that the client uses
> contains the following input line:
>
> <input type=file size=30 name=file_name>
>
> and the form that contains that invokes a script
>
> #!/bin/bash
> tf=/tmp/fdat$$
> cat > $tf
> ./pfdat $tf "$REMOTE_ADDR" "$HTTP_USER_AGENT" "$$"
>
> that, as you can see, invokes a j #! script named pfdat
> In turn, that script reads the /tmp file and processes
> it (with an arbitrary 20 megabyte limit on file size).
> This seems to work pretty well.
>
> I can provide further details if interested. If there
> is insight into why there is a buffer overflow in stdin,
> I would be very interested in knowing more about it.
>
> - joey
>
> At 6:48 -0700 2006/02/21, Lorin Lund wrote:
>>John Randall wrote:
>>
>>>Lorin:
>>>
>>>Are you reading from an actual file or a socket? I have had no trouble
>>>using stdin to read from a file or pipe, even for large files. For
>>>sockets, I had the symptoms you described until I wrote code to keep
>>>rechecking until the socket is fully read. If this is the issue, I can
>>>post what I use.
>>>
>>>Best wishes,
>>>
>>>John
>>>
>>>
>>I am reading from a pipe from httpd. It isn't a matter of not
>>getting all the data. It is a matter of getting an error.
>>
>>If I put a "try. catch." bracket around the read I can go on
>>without the data. But without that it dies there. But because the
>>server I'm using has hit logs but no error logs (as far as I have
>>found so far) I don't know if J is giving an error message or what
>>it might be.
>>
>>
>>
>>----------------------------------------------------------------------
>>For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm