<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/2be1dd0bb03dbb1d3a23a846c7e57647"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-03T19:36:55"
  subject="Re: [Caml-list] camlp4 in script"
  prev="2003/11/1d87c05e41bbe7ce253007f8039e67d7"
  next="2003/11/de3fb293ab7d64f03a57f202ae9fc467"
  prev-in-thread="2003/11/ef8d11d2a3f4c6fd8183db8286734f46"
  next-in-thread="2003/11/de3fb293ab7d64f03a57f202ae9fc467"
  prev-thread="2003/11/96c5a045d70b126cf9ebbe6b346fc3dd"
  next-thread="2003/11/1d87c05e41bbe7ce253007f8039e67d7"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] camlp4 in script">
<msg 
  url="2003/11/ef8d11d2a3f4c6fd8183db8286734f46"
  from="Artem Prisyznuk &lt;tema@s...&gt;"
  author="Artem Prisyznuk"
  date="2003-11-03T15:05:39"
  subject="[Caml-list] camlp4 in script">
<msg 
  url="2003/11/2be1dd0bb03dbb1d3a23a846c7e57647"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-03T19:36:55"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/de3fb293ab7d64f03a57f202ae9fc467"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2003-11-03T21:11:27"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/8163dd559883060e93e84dc62f5d126b"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-04T00:52:03"
  subject="Re: [Caml-list] camlp4 in script">
</msg>
</msg>
</msg>
<msg 
  url="2003/11/4f6f0f0d0e94235cac264fe76793b7fc"
  from="Remi Vanicat &lt;vanicat@l...&gt;"
  author="Remi Vanicat"
  date="2003-11-04T09:16:32"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/b332712b2d47a9c682bab732f273ca3b"
  from="Artem Prisyznuk &lt;tema@s...&gt;"
  author="Artem Prisyznuk"
  date="2003-11-04T09:45:54"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/2c0eec700da6320a17bcd3d2469d1a05"
  from="Lars Nilsson &lt;lars@c...&gt;"
  author="Lars Nilsson"
  date="2003-11-04T14:58:08"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/371fcb184f3608c4dffc91d3b3724c72"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-04T20:01:27"
  subject="Re: [Caml-list] camlp4 in script">
<msg 
  url="2003/11/591624a3bf7e87f6649a6d81577181bf"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-04T21:15:36"
  subject="Re: [Caml-list] camlp4 in script">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/11/7c2a1cb12f95300a9f19c0db7c2ad6e0"
  from="Stefano Zacchiroli &lt;zack@b...&gt;"
  author="Stefano Zacchiroli"
  date="2003-11-05T08:24:38"
  subject="Re: [Caml-list] camlp4 in script">
</msg>
</msg>
</thread>

<contents>
On Mon, Nov 03, 2003 at 05:06:00PM +0200, Artem Prisyznuk wrote:
&gt; Hello,
&gt; 
&gt; If I want call ocaml script from shell I type next header for
&gt; this script:
&gt; 
&gt;   #!/usr/bin/ocamlrun /usr/bin/ocaml
&gt; 
&gt;   print_string "Hello\n";;
&gt;   .....
&gt; 
&gt; 
&gt; But if I want use camlp4 for source of script, I try next source
&gt; 
&gt;   #!/usr/bin/ocamlrun /usr/bin/ocaml -I `camlp4 -where`
&gt; 
&gt;   #load "camlp4r.cma";
&gt;   print_string "Hello\n";
&gt;   .....
&gt; 
&gt; 
&gt; When I try execute this script shell print next error:
&gt; 
&gt;   Fatal error: cannot find file /usr/bin/ocaml -I /usr/lib/ocaml/camlp4
&gt; 
&gt; 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 -&gt; ()
    | _ -&gt; 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

</contents>

</message>

