Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: [Caml-list] "Hello web" please

6 views
Skip to first unread message

Christophe TROESTLER

unread,
Jul 8, 2006, 4:50:42 PM7/8/06
to christos.jon...@gmail.com, caml...@yquem.inria.fr
On Sat, 8 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" <christos.jon...@gmail.com> wrote:
>
> I'm trying to figure out how to use CamlGI with OCaml, [...]

CamlGI code has been integrated into the Netcgi component
<https://gps.dynxs.de/wwwsvn/trunk/code/src/netcgi/?root=lib-ocamlnet2>
of OcamlNet-2 <https://gps.dynxs.de/openapps/svnindex.cgi>, please use
that instead.

> [...] script that [...] prints a webpage saying only "Yes", "No",
> "Other" or "Undefined" depending on whether the CGI variable "foo"
> has value 1, 0, some other defined value, or is undefined (never
> mind about multiple values)?

You can find examples in the examples/ directory (add.ml is a very
simple one). As for the specific example you desire, it is attached.
It is maybe a bit more complex that you expected because it
demonstrates additional features (text escaping, setting the header,
buffered output).

Hope it helps,
ChriS

hello.ml

Christophe TROESTLER

unread,
Jul 10, 2006, 11:17:20 AM7/10/06
to christos.jon...@gmail.com, caml...@yquem.inria.fr
On Mon, 10 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" <christos.jon...@gmail.com> wrote:
>
> I've been urged to use Netcgi from OcamlNet-2 from
> http://www.ocaml-programming.de/packages/ocamlnet-2.2test2.tar.gz .

Ok. I was pointing you to the subversion repository so you can browse
the files and see whether that is what you need. You can download the
files with

svn co https://gps.dynxs.de/svn/lib-ocamlnet2/trunk/ lib-ocamlnet2

> When I tried to configure OcamlNet2 it said it needed PCRE -- and even
> though I installed what was labelled as PCRE from
> ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ , OcamlNet-2 refused
> to configure because it couldn't recognize PCRE as being installed, and when
> I commented out the test for PCRE in the configure it still couldn't find
> it.

You need the OCaml interface to the C library. Get it here:
http://ocaml.info/home/ocaml_sources.html#toc13

Hope it helps,
ChriS

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Christophe TROESTLER

unread,
Jul 10, 2006, 11:50:50 AM7/10/06
to christos.jon...@gmail.com, caml...@yquem.inria.fr
On Mon, 10 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" <christos.jon...@gmail.com> wrote:
>
> What should the shebang line say?
> #!/usr/local/bin/ocaml

#!/usr/local/bin/ocamlrun ocaml

You also need to load the necessary libraries:

#load "pcre.cma";;
#load "unix.cma";;
...
#load "netcgi.cma";;

(see attached file).

> when I run it from within apache I get an internal server error. (A
> copy of the command line output follows the script).

Do you run is as CGI ? Also beware that the newer Netcgi module is
not in the tarball you mentioned. Get the SVN version if you want to
use it (I am not sure the build system already compiles it as its
insersion is very recent but I can fix that).

Cheers,
ChriS

script.ml

Jonathan Roewen

unread,
Jul 10, 2006, 11:53:39 AM7/10/06
to Jonathan Hayward http://JonathansCorner.com, caml...@yquem.inria.fr
> #!/usr/local/bin/ocaml

you might want to try:

#!/usr/local/bin/ocamlrun ocaml

This is what I had to do with my webhost for some reason.

Maxence Guesdon

unread,
Jul 11, 2006, 10:40:38 AM7/11/06
to caml...@yquem.inria.fr
On Tue, 11 Jul 2006 10:23:24 -0400
"Jonathan Hayward http://JonathansCorner.com"
>...

Hello,

> let main (cgi:cgi) =
> cgi#set_header
> ~cache:`No_cache
> ~content_type:"text/html; charset=\"iso-8859-1\""
> ();
> let foo = cgi#argument_value "foo"
Maybe "in" is missing here ? ^^

Hope this helps,

--
Maxence Guesdon
http://yquem.inria.fr/~guesdon/
http://devel.inria.fr/rocq/

Christophe TROESTLER

unread,
Jul 11, 2006, 10:46:58 AM7/11/06
to christos.jon...@gmail.com, caml...@yquem.inria.fr
On Tue, 11 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" <christos.jon...@gmail.com> wrote:
>
> File "./demo.ml", line 35, characters 2-5:
> Syntax error
>
> The line in question is:
>
> | "1" -> "Yes"
>
> Is there some irritating little syntax error around line 35?

Well, I do not know the reason but it is the second time "you"
suppresses the necessary "in". The line

> let foo = cgi#argument_value "foo"

should read

let foo = cgi#argument_value "foo" in

(it is present in my attached file, what happened???)

ChriS

Christophe TROESTLER

unread,
Jul 11, 2006, 2:17:11 PM7/11/06
to christos.jon...@gmail.com, O'Caml Beginners Mailing List, O'Caml Mailing List
On Tue, 11 Jul 2006, "Jonathan Hayward" <christos.jon...@gmail.com> wrote:
>
> Thank you; it seems to compile now, but it's crashing (runtime); there's a
> library installed on my system that it's not picking up.

The way it is, the script is NOT compiled, it is interpreted. I
recommend you compile it to bytecode
(http://caml.inria.fr/pub/docs/manual-ocaml/manual022.html) or native
code (http://caml.inria.fr/pub/docs/manual-ocaml/manual025.html)
however.

> jonathan@inner-sanctum:~/csi/ml$ ocamlrun ocaml ./demo.ml
> Cannot load required shared library dllpcre_stubs.
> Reason: dllpcre_stubs.so: cannot open shared object file: No such file or
> directory.

I do not have that problem (get Debian :). Does the script run from
the command line? Maybe setting the environment variable
LD_LIBRARY_PATH can help?

I propose to continue this conversation on the beginner mailing list
(http://groups.yahoo.com/group/ocaml_beginners/) to which I also sent
this message.

Jonathan Roewen

unread,
Jul 12, 2006, 7:24:47 AM7/12/06
to Jonathan Hayward http://JonathansCorner.com, caml...@inria.fr
Make your life simpler, and install findlib ;-) (The presence of
site-lib for the path to pcre indicates it'll work out of the box)

In a script, you can do:

#use "topfind";;

#require "pcre";;

at this point, it'll have loaded all the necessary .cma & .cmi files,
added path to the .cmi/.mli files to the search path, and also resolve
any dependencies.

0 new messages