Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Unix and Cgi
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-11-13 (02:09)
From: wakita <wakita@i...>
Subject: Re: [Caml-list] Unix and Cgi

In message (<>)
from "Willem Duminy" <>,
talking about "[Caml-list] Unix and Cgi",
on Mon, 12 Nov 2001 08:32:38 +0200

> Hi Guys,
> I am experimenting with ocaml and cgi on Linux/Apache.  A handy thing to
> have is the ability to execute a shell command and use the result of it
> in your cgi program.  
> So I used open_process_in from the Unix lib to execute the exeternal
> command.  This all works well when run from the console - but when I run
> the same program from cgi - the channel_in contains no information.  I
> thought it may have to do with the fact that the execution runs in a
> spearate thread - maybe cgi does not allow this.
> If you have experienced the same problem or have any ideas/hints, please
> help.
> Regards

Unix.channel_in does not require write permission but I presumed that
your shell script (i don't know what kind) requires.  If the CGI fails
due to a runtime error, most probablly you can find an "Uncaught
exception" error in the error log of the httpd server.  Better
approach is trap all the exception in your main routine and show it if
an error occurs.  The following code fragment may help:

let _ =
  try your_CGI_code ()
  with exc ->
    Cgi.header "";
    printf "<html><title>Error!</title><body>%s</body></html>"
      (Printexc.to_string exc)    

Good luck,
Bug reports:  FAQ:
To unsubscribe, mail  Archives: