From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA31312; Mon, 3 Nov 2003 20:36:55 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA12473 for ; Mon, 3 Nov 2003 20:36:54 +0100 (MET) Received: from pop9.ucdavis.edu (pop9.ucdavis.edu [169.237.105.19]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hA3Jaq104281 for ; Mon, 3 Nov 2003 20:36:53 +0100 (MET) Received: from beech (beech.ucdavis.edu [128.120.141.134]) by pop9.ucdavis.edu (8.12.9/8.12.9/it-std-5.0.2) with ESMTP id hA3JaoEV005164 for ; Mon, 3 Nov 2003 11:36:50 -0800 (PST) Received: from ijtrotts by beech with local (Exim 3.36 #1 (Debian)) id 1AGkeF-0002WR-00 for ; Mon, 03 Nov 2003 11:45:59 -0800 Date: Mon, 3 Nov 2003 11:45:59 -0800 From: Issac Trotts To: caml-list@inria.fr Subject: Re: [Caml-list] camlp4 in script Message-ID: <20031103194559.GB9184@ucdavis.edu> Reply-To: ijtrotts@ucdavis.edu References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; issac:01 trotts:01 ijtrotts:01 caml-list:01 camlp:01 artem:01 usr:01 ocamlrun:01 usr:01 camlp:01 ocamlrun:01 -where:01 ijtrotts:01 argv:01 printf:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Nov 03, 2003 at 05:06:00PM +0200, Artem Prisyznuk wrote: > Hello, > > If I want call ocaml script from shell I type next header for > this script: > > #!/usr/bin/ocamlrun /usr/bin/ocaml > > print_string "Hello\n";; > ..... > > > But if I want use camlp4 for source of script, I try next source > > #!/usr/bin/ocamlrun /usr/bin/ocaml -I `camlp4 -where` > > #load "camlp4r.cma"; > print_string "Hello\n"; > ..... > > > When I try execute this script shell print next error: > > Fatal error: cannot find file /usr/bin/ocaml -I /usr/lib/ocaml/camlp4 > > How I can execute script witch revised syntax? It works if you make an executable that wraps the call to ocaml with the desired arguments: ijtrotts@beech:/tmp$ cat c4.ml let () = let includes = "-I /usr/lib/ocaml/camlp4" in let args = List.fold_left (^) "" (List.tl (Array.to_list Sys.argv)) in let cmd = Printf.sprintf "ocaml %s camlp4r.cma %s" includes args in match Sys.command cmd with 0 -> () | _ -> prerr_endline ("Couldn't run "^cmd) ijtrotts@beech:/tmp$ ocamlopt -o c4 c4.ml ijtrotts@beech:/tmp$ su Password: beech:/tmp# mv c4 /usr/local/bin/c4 ijtrotts@beech:/tmp$ cat foo.ml #!/usr/local/bin/c4 print_string "Hello\n"; ijtrotts@beech:/tmp$ chmod +x foo.ml ijtrotts@beech:/tmp$ ./foo.ml Hello -ijt -- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners