I need help getting Ocamlnet to work at a basic level. I tried running the script from the command-like to more easily access diagnostic output. What should the shebang line say? Right now I have the following (mostly) paste of the demo script, plus shebang line; when I run it from within apache I get an internal server error. (A copy of the command line output follows the script). -- #!/usr/local/bin/ocaml 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" 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 -- Couldnt get a file descriptor referring to the console Could not get a file descriptor referring to the console ./demo.ml: line 4: let: =: syntax error: operand expected (error token is "=") ./demo.ml: line 5: demo.ml: command not found ./demo.ml: line 6: characters: command not found ./demo.ml: line 7: text: command not found ./demo.ml: line 9: demo.ml: command not found ./demo.ml: line 10: syntax error near unexpected token `(' ./demo.ml: line 10: `let html_page (cgi:cgi) title html =' -- On 7/8/06, Christophe TROESTLER wrote: > > On Sat, 8 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" < > christos.jonathan.hayward@gmail.com> wrote: > > > > I'm trying to figure out how to use CamlGI with OCaml, [...] > > CamlGI code has been integrated into the Netcgi component > > of OcamlNet-2 , 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 > > > 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 " \"http://www.w3.org/TR/REC-html40/strict.dtd\">\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" > 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 > > > -- ++ Jonathan Hayward, jonathan.hayward@pobox.com ** To see an award-winning website with stories, essays, artwork, ** games, and a four-dimensional maze, why not visit my home page? ** All of this is waiting for you at http://JonathansCorner.com ** If you'd like a Google Mail (gmail.com) account, please tell me!