Ocamlscript 2 derives from David Mentre's original implementation and adds
support for findlib packages, camlp4 syntax extensions, ocamllex,
ocamllyacc, input from stdin, script on the command-line, and some support
for compilation and linking with other source files. In theory it can also
be configured to support any compiled programming language other than
ocamlscript compiles scripts, i.e. one-file programs, into
natively-compiled binaries, and executes them.
Basically, a script named alpha is compiled into alpha.exe. If alpha.exe
is more recent than alpha, then alpha.exe is executed directly, otherwise
alpha is recompiled first.
Compilation commands reside in the first section of the script. They are
written in OCaml and consist normally in setting one or two variables.
The following "getpage" script fetches a web page using the HTTP client
provided by the netclient library/findlib package:
#! /usr/bin/env ocamlscript
Ocaml.packs := [ "netclient" ]
match Sys.argv with
[| _; url |] -> print_string (Http_client.Convenience.http_get url)
| _ -> prerr_string "Usage: getpage URL\n"; exit 1
For instance, executing "getpage http://caml.inria.fr" creates a
getpage.exe file in the same directory as "getpage", runs it and prints
the web page that was requested.
Caml-list mailing list. Subscription management:
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs