* [Caml-list] camlp4 in script
@ 2003-11-03 15:06 Artem Prisyznuk
2003-11-03 19:45 ` Issac Trotts
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Artem Prisyznuk @ 2003-11-03 15:06 UTC (permalink / raw)
To: caml-list
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?
--
Artem Prysyznuk
tema@sit.kiev.ua
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-03 15:06 [Caml-list] camlp4 in script Artem Prisyznuk
@ 2003-11-03 19:45 ` Issac Trotts
2003-11-03 21:11 ` William Lovas
2003-11-04 9:16 ` Remi Vanicat
2003-11-05 7:54 ` Stefano Zacchiroli
2 siblings, 1 reply; 10+ messages in thread
From: Issac Trotts @ 2003-11-03 19:45 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-03 19:45 ` Issac Trotts
@ 2003-11-03 21:11 ` William Lovas
2003-11-04 1:01 ` Issac Trotts
0 siblings, 1 reply; 10+ messages in thread
From: William Lovas @ 2003-11-03 21:11 UTC (permalink / raw)
To: caml-list
On Mon, Nov 03, 2003 at 11:45:59AM -0800, Issac Trotts wrote:
> 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))
I don't think this is what you want -- this will concatenate the arguments
without putting any whitespace between them. Maybe:
let args =
String.concat " " (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)
>
> [...]
cheers,
William
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-03 21:11 ` William Lovas
@ 2003-11-04 1:01 ` Issac Trotts
0 siblings, 0 replies; 10+ messages in thread
From: Issac Trotts @ 2003-11-04 1:01 UTC (permalink / raw)
To: William Lovas; +Cc: caml-list
On Mon, Nov 03, 2003 at 04:11:22PM -0500, William Lovas wrote:
> On Mon, Nov 03, 2003 at 11:45:59AM -0800, Issac Trotts wrote:
> > 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))
>
> I don't think this is what you want -- this will concatenate the arguments
> without putting any whitespace between them. Maybe:
>
> let args =
> String.concat " " (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)
> >
> > [...]
You're right. Thanks for catching it.
Issac
--
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-03 15:06 [Caml-list] camlp4 in script Artem Prisyznuk
2003-11-03 19:45 ` Issac Trotts
@ 2003-11-04 9:16 ` Remi Vanicat
2003-11-04 9:46 ` Artem Prisyznuk
2003-11-05 7:54 ` Stefano Zacchiroli
2 siblings, 1 reply; 10+ messages in thread
From: Remi Vanicat @ 2003-11-04 9:16 UTC (permalink / raw)
To: Artem Prisyznuk; +Cc: caml-list
Artem Prisyznuk <tema@sit.kiev.ua> writes:
> 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";
> .....
You could try :
#!/usr/bin/ocamlrun /usr/bin/ocaml
#directory "+camlp4";;
#load "camlp4r.cma";;
print_string "Hello\n";
--
Rémi Vanicat
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-04 9:16 ` Remi Vanicat
@ 2003-11-04 9:46 ` Artem Prisyznuk
2003-11-04 14:59 ` Lars Nilsson
0 siblings, 1 reply; 10+ messages in thread
From: Artem Prisyznuk @ 2003-11-04 9:46 UTC (permalink / raw)
To: Remi Vanicat; +Cc: caml-list
On Tue, 04 Nov 2003 10:16:54 +0100, Remi Vanicat
<vanicat@labri.u-bordeaux.fr> wrote:
> You could try :
> #!/usr/bin/ocamlrun /usr/bin/ocaml
>
> #directory "+camlp4";;
> #load "camlp4r.cma";;
> print_string "Hello\n";
Thanks a lot, it work.
--
Artem Prysyznuk
tema@sit.kiev.ua
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-04 9:46 ` Artem Prisyznuk
@ 2003-11-04 14:59 ` Lars Nilsson
2003-11-04 20:10 ` Issac Trotts
0 siblings, 1 reply; 10+ messages in thread
From: Lars Nilsson @ 2003-11-04 14:59 UTC (permalink / raw)
To: caml-list
Just out of curiousity, wouldn't creating a new toplevel using
something like
ocamlmktop -I +camlp4 -custom -o ocamlp4rsh camlp4r.cma
and using
#!/somedir/ocamlp4rsh
be a nice solution for this particular problem? No need for the two
additional lines in this case.
I'm sort of wondering why no-one has suggested it before me (could be
related to me not knowing what I'm saying quite possibly).
Lars
Artem Prisyznuk writes:
> On Tue, 04 Nov 2003 10:16:54 +0100, Remi Vanicat
> <vanicat@labri.u-bordeaux.fr> wrote:
>
>
> > You could try :
> > #!/usr/bin/ocamlrun /usr/bin/ocaml
> >
> > #directory "+camlp4";;
> > #load "camlp4r.cma";;
> > print_string "Hello\n";
>
> Thanks a lot, it work.
>
> --
> Artem Prysyznuk
> tema@sit.kiev.ua
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-04 14:59 ` Lars Nilsson
@ 2003-11-04 20:10 ` Issac Trotts
[not found] ` <16296.2885.478524.117242@gargle.gargle.HOWL>
0 siblings, 1 reply; 10+ messages in thread
From: Issac Trotts @ 2003-11-04 20:10 UTC (permalink / raw)
To: caml-list
On Tue, Nov 04, 2003 at 09:59:10AM -0500, Lars Nilsson wrote:
> Just out of curiousity, wouldn't creating a new toplevel using
> something like
>
> ocamlmktop -I +camlp4 -custom -o ocamlp4rsh camlp4r.cma
>
> and using
>
> #!/somedir/ocamlp4rsh
>
> be a nice solution for this particular problem? No need for the two
> additional lines in this case.
>
> I'm sort of wondering why no-one has suggested it before me (could be
> related to me not knowing what I'm saying quite possibly).
I think no one suggested it because ocamlmktop creates a toplevel
that doesn't automatically include the +camlp4 directory.
The -I +camlp4 directive passed to ocamlmktop is only used to
find the .cmo and .cma files while making the new toplevel.
--
Issac Trotts
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
[not found] ` <16296.2885.478524.117242@gargle.gargle.HOWL>
@ 2003-11-04 21:24 ` Issac Trotts
0 siblings, 0 replies; 10+ messages in thread
From: Issac Trotts @ 2003-11-04 21:24 UTC (permalink / raw)
To: caml-list
On Tue, Nov 04, 2003 at 03:25:41PM -0500, Lars Nilsson wrote:
> > I think no one suggested it because ocamlmktop creates a toplevel
> > that doesn't automatically include the +camlp4 directory.
> > The -I +camlp4 directive passed to ocamlmktop is only used to
> > find the .cmo and .cma files while making the new toplevel.
>
> That could explain some of my problems I had when trying to test it. I
> just put it down as a complete lack of understanding of how to work
> with camlp4 (I haven't felt a deep need for it before, so much of it
> is still a mystery to me). I did get something working, but it was a
> very tiny example, and perhaps it just didn't reference anything in
> manner that would require the #directory statement (I think I just
> used the stream parser functionality in camlp4o).
That's probably it. My earlier post in this thread shows how to work around
this problem by making a new executable that makes a system call
to the ocaml toplevel with the extra -I arguments.
--
Issac Trotts
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] camlp4 in script
2003-11-03 15:06 [Caml-list] camlp4 in script Artem Prisyznuk
2003-11-03 19:45 ` Issac Trotts
2003-11-04 9:16 ` Remi Vanicat
@ 2003-11-05 7:54 ` Stefano Zacchiroli
2 siblings, 0 replies; 10+ messages in thread
From: Stefano Zacchiroli @ 2003-11-05 7:54 UTC (permalink / raw)
To: caml-list
On Mon, Nov 03, 2003 at 05:06:00PM +0200, Artem Prisyznuk wrote:
> 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";
Using findlib you can do something like this:
#!/usr/bin/ocamlrun /usr/bin/ocaml
#use "topfind";;
#camlp4r;;
print_string "Hello\n";
Cheers.
--
Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/
" I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant! " -- G.Romney
-------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-11-05 8:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-03 15:06 [Caml-list] camlp4 in script Artem Prisyznuk
2003-11-03 19:45 ` Issac Trotts
2003-11-03 21:11 ` William Lovas
2003-11-04 1:01 ` Issac Trotts
2003-11-04 9:16 ` Remi Vanicat
2003-11-04 9:46 ` Artem Prisyznuk
2003-11-04 14:59 ` Lars Nilsson
2003-11-04 20:10 ` Issac Trotts
[not found] ` <16296.2885.478524.117242@gargle.gargle.HOWL>
2003-11-04 21:24 ` Issac Trotts
2003-11-05 7:54 ` Stefano Zacchiroli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox