From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4774CBB84 for ; Mon, 10 Jul 2006 17:48:26 +0200 (CEST) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6AFmLCc015400 for ; Mon, 10 Jul 2006 17:48:26 +0200 Received: from poincare.swapping.umh.ac.be (mathwifi.swapping.umh.ac.be [10.102.100.203]) by hedwig1.umh.ac.be (8.13.6/8.13.6) with ESMTP id k6AFo8871245392; Mon, 10 Jul 2006 17:50:08 +0200 Received: from localhost ([127.0.0.1]) by poincare.swapping.umh.ac.be with esmtp (Exim 4.62) (envelope-from ) id 1FzxzX-0003mO-9b; Mon, 10 Jul 2006 17:48:11 +0200 Date: Mon, 10 Jul 2006 17:48:00 +0200 (CEST) Message-Id: <20060710.174800.180966261.Christophe.Troestler@umh.ac.be> To: christos.jonathan.hayward@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] "Hello web" please From: Christophe TROESTLER In-Reply-To: References: <20060708.224756.70330795.Christophe.Troestler@umh.ac.be> X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: Universite de Mons-Hainaut (http://math.umh.ac.be/an/) X-Spook: ANDVT espionage cracking Kh-11 kilo class Ft. Meade Mossad terrorist target industrial espionage X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Operating-System: Debian GNU/Linux (http://www.debian.org/) X-Mailer: Mew version 4.2.52 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Jul_10_17_48_00_2006_040)--" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-Miltered: at concorde with ID 44B276C5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe:01 troestler:01 christophe:01 troestler:01 umh:01 usr:01 ocaml:01 usr:01 ocamlrun:01 ocaml:01 pcre:01 unix:01 netcgi:01 netcgi:01 tarball:01 X-Attachments: name="script.ml" X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 ----Next_Part(Mon_Jul_10_17_48_00_2006_040)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit On Mon, 10 Jul 2006, "Jonathan Hayward http://JonathansCorner.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 ----Next_Part(Mon_Jul_10_17_48_00_2006_040)-- Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="script.ml" #!/usr/bin/ocamlrun ocaml (* Change the directories as needed for your system. *) #directory "+pcre";; #load "pcre.cma";; #load "unix.cma";; #directory "+netstring";; #load "netstring.cma";; #directory "/path/to/netcgi/";; #load "netcgi.cma";; open Netcgi let text = Netencoding.Html.encode_from_latin1 (* This function encodes "<", ">", "&", double quotes, and Latin 1 characters as character entities. E.g. text "<" = "<", and text "ä" = "ä" *) (* Normally you would use a template system instead of this *) let html_page (cgi:cgi) title html = let out = cgi#out_channel#output_string in out "\n"; out ("\n" ^ text title ^" \n"); out html; out "\n" let main (cgi:cgi) = cgi#set_header ~cache:`No_cache ~content_type:"text/html; charset=\"iso-8859-1\"" (); let foo = cgi#argument_value "foo" in let html = match foo with | "1" -> "Yes" | "0" -> "No" | _ -> "Undefined" in html_page cgi foo html (* You can buffer or not the output. If buffered you can rollback (useful in case of error). You can replace Netcgi_cgi.run by another connector entry point (FCGI, SCGI, AJP, Apache mod). *) let () = let buffered _ ch = new Netchannels.buffered_trans_channel ch in Netcgi_cgi.run ~output_type:(`Transactional buffered) main ----Next_Part(Mon_Jul_10_17_48_00_2006_040)----