At 12:25 +0800 2007/01/22, bill lam wrote:
Joey K Tuttle wrote:
I'm not sure about what standards say, but in creating a file
uploading facility in Linux/Apache, I had troubles with large
objects via a CGI post call. As I recall, the troubles began
at only a few hundred KB - but this may have been exacerbated by
My question may be related to what should be the expected behaviour
of reading stdin when it is empty.
in j ide, calling a=.1!:1[3 will retrun an empty string immediately,
but in jconsole, it wait for input if stdin is empty.
in c or perl, isn't that reading an empty stdin will suspense
execution until there is data in stdin for reading?
in cgi, will only one reading on stdin getting all data, or it needs
multiple reading of stdin until all data be read as indicated by env
variable content_length?
I googled and found there is a built-in facility in cgi.pm to
handling uploading file but it seems not applicable directly to J at
least not without digging into its source code.
--
regards,
bill
The question of empty STDIN is an interesting one. I have
made comments about that over the years, and the current j
distributions have a small addition to jmf that lets a j
script determine if it is running in a shell and then read
STDIN (which comes as a single buffer, with some size limit).
I have not bothered to try to make a read stdin loop, e.g.
my file upload example. I'm happy to share more scripts if
that is any help to folks.
The j verb that I use at the top of my j CGI scripts (note
that I'm running j504 in my server - hence x. y. are used) is
getargs =: 3 : 0
ARGV getargs y.
:
require 'jmf'
argb =. (]`(([: < 1: {. }.) , [: < 2: }. ])@.('-'"_ = {.))&.> x.
NB. The above boxes parms (elements starting with "-" returning name;value
parm =. 32 = ;(3!:0)&.> argb
((-. parm)#argb);(>parm#argb);(". ({. 0 = >c_isatty_jmf_ 0)#'stdin ''''')
)
A template of my CGI shell scripts looks like this:
#! /usr/local/bin/ja
localverbs =: 3 : 'may be defined here'
3 : 0 ARGV
try. NB. catch errors.
'call parms stin' =: getargs 'no fancy parms...' NB. parms e.g.
-a10 <-> (,'a');'10'
if. ((0 = #stin) *. 3 > # call) do.
stderr 'Usage: ',(;1{call), ' argument list',NL
exit 2
else.
NB. Do the work here
stdout some result
end.
catch.
stderr 13!:12 '' NB. at the very least...
end.
exit 0
)
That leaves out processing the results of "parms" and "stin" --
and makes me feel guilty about not having a wiki page that is
more verbose...
- joey
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm