Hi,
Thanks for your reply. My original message was possibly a bit confusing.
The script is not intended to be run on a local machine but inside a web
server.
Here is (perhaps) a better explanation of my question:
A standard way to upload files from a local machine to a server via a
web page is by use of something like PHP or perl as a cgi program
executed on the server.
After successfully writing an n-Queens servlet using Oz (for servlet
read server-side cgi program) I wondered if Oz could be used like PHP to
upload files.
From my reading, and limited understanding about PHP/perl file
uploading I found that to upload a file with these languages, the server
effectively passes the file to the STDIN of the cgi program. This is
what I am trying to read with
StdIn={New Open.file init(name:stdin flags:[read])}
Env={StdIn read(list:$)}
but I don't seem to be receiving anything. My script doesn't even care
at the moment whether the received data is a file or not, it just
attempts to display whatever is received on STDIN inside some HTML. Your
test at the console seems to show that STDIN is indeed being read and
processed, but the same does not seem to occur inside a server.
The major problem I have is that debugging is very difficult since the
program must execute within the web server (Apache2) so I can't
interactively debug it.
I appreciate as you have said you might not be able to offer any further
help as far as cgi is concerned but perhaps someone else might better
understand what I am actually asking although I think from the lack of
replies that either no one has tried to do this before or everyone is on
summer vacation :+)
Thanks for your help
Regards
Mark
On 07/07/10 14:12, Boriss Mejias wrote:
Hi Mark,
I don't understand why you are trying to do (basically because I have
never worked with cgi-bin servlets). But I tried running your code on
the console, and this is what I got after typing "this is a test"
----------------------------------------------------------------------------
mymachine> ./test
this is a test
Content-type: text/html
<html><head><title>Upload files using Oz</title></head><body
bgcolor="#f0f0e0"><h1>Oz file upload</h1><p>The data received was:this
is a test
</p></body></html>
----------------------------------------------------------------------------
So I decided to feed the program with its own code as input, and this
is what I got:
----------------------------------------------------------------------------
mymachine> ./test < test.oz
Content-type: text/html
<html><head><title>Upload files using Oz</title></head><body
bgcolor="#f0f0e0"><h1>Oz file upload</h1><p>The data received
was:%%cgi-bin program to accept file uploads
functor
import
Open
Application
OS
define
StdIn={New Open.file init(name:stdin flags:[read])}
Env={StdIn read(list:$)}
Out={New class $
from Open.file Open.html
end
init(name:stdout)}
%% Print MIME content header
{Out header}
{Out tag(html(head(title('Upload files using Oz'))
body(bgcolor:'#f0f0e0'
h1('Oz file upload')
p('The data received was:'#Env)
)))}
{Application.exit 0}
end
</p></body></html>
----------------------------------------------------------------------------
That's the only help I can provide.
cheers
Boriss
Mark richardson wrote:
Hi,
I wonder if anyone has any experience using Oz for cgi-bin servlets?
I've already successfully created one to give a solution for n-queens
for a submitted board size so I know I can use the facility properly.
What I'm now trying to do is create an 'upload-file' servlet in oz.
As far as I understand the operation of cgi (and I'm no expert!), in the
case of file uploads the data for the file itself is passed via the
servlets stdin.
So, I have the following functor definition:
%%cgi-bin program to accept file uploads
functor
import
Open
Application
OS
define
StdIn={New Open.file init(name:stdin flags:[read])}
Env={StdIn read(list:$)}
Out={New class $
from Open.file Open.html
end
init(name:stdout)}
%% Print MIME content header
{Out header}
{Out tag(html(head(title('Upload files using Oz'))
body(bgcolor:'#f0f0e0'
h1('Oz file upload')
p('The data received was:'#Env)
)))}
{Application.exit 0}
end
I'm not currently worried about what actually is received, I'd be happy
at the moment to see anything coming into 'Env'. My problem is that I
appear to be receiving nil. The servlet executes but nothing appears
after "The data received was:".
The difficulty is that I can't see any way of debugging this except
executing it through the web server, so I don't know if 'something' has
been received or not.
Any advice would be gratefully received.
Regards
Mark
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
--
Mark Richardson MBCS
Email: [email protected]
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users