From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA30779 for caml-redistribution; Thu, 8 Jul 1999 03:43:09 +0200 (MET DST) 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 LAA29256 for ; Mon, 5 Jul 1999 11:37:29 +0200 (MET DST) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA02651 for ; Mon, 5 Jul 1999 11:37:27 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id LAA30606; Mon, 5 Jul 1999 11:37:25 +0200 (MET DST) From: Markus Mottl Message-Id: <199907050937.LAA30606@miss.wu-wien.ac.at> Subject: Re: Sys.argv with interpreter and compiler To: luther@dpt-info.u-strasbg.fr Date: Mon, 5 Jul 1999 11:37:25 +0100 (MET DST) Cc: caml-list@inria.fr (OCAML) In-Reply-To: <19990705100950.A3414@maxime.u-strasbg.fr> from "Sven LUTHER" at Jul 5, 99 10:09:50 am X-Mailer: ELM [version 2.4 PL21] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis > I don't get the same, why : > > sh-2.02$ cat essay > #!/usr/local/bin/ocaml > print_string "Hello world!"; print_newline();; > exit 0;; > ^D > sh-2.02$ ./essai > ./essai: line 2: syntax error near unexpected token `;' > ./essai: line 2: `print_string "Hello world!"; print_newline();;' Your toplevel "/usr/local/bin/ocaml" is obviously compiled to byte code. Take a look at it with "less" and you will see that the first line of this executable is actually "#!/home/mottl/mysys/bin/ocamlrun". As far as I know it is not allowed on any unix system to run scripts whose interpreter is a script itself. This would make it much easier to replace this interpreter with something evil - e.g. some kind of wrapper that executes unfriendly commands under you UID and continues with the "true" interpreter. Try the difference like this: ocamlmktop -o newtop Now place replace "#!/usr/local/bin/ocaml" with the path to the newly created "newtop" and run "essay" again - you will again receive an error message, because the system will run the script with your current shell instead with "newtop" which is not a "true" binary. Then execute: ocamlmktop -custom newtop This will generate a native code (=true binary) toplevel. You might want to link useful native code libraries to it, eg. "unix", "str", even "threads" and graphics work just fine! If you run "essay" again, it will work out of the box... I have linked my own "toplevel" like this (under Linux -> native threads supported!): ocamlmktop -thread -custom -o mocaml \ graphics.cma -cclib -lgraphics -ccopt -L/usr/X11R6/lib -cclib -lX11 \ unix.cma -cclib -lunix \ str.cma -cclib -lstr \ threads.cma -cclib -lthreads -cclib -lunix -cclib -lpthread This allows me to run virtually every kind of Ocaml-script from the shell. Try "mocaml" with this little program under X-windows: open Graphics open Random let main () = open_graph ""; let sx, sy = size_x (), size_y () in let maxr = min (sx lsr 2) (sy lsr 2) and maxc = 256 in while not (key_pressed ()) do let x, y, r, color = int sx, int sy, int maxr, rgb (int maxc) (int maxc) (int maxc) in set_color color; fill_circle x y r done let _ = Printexc.catch main () Nice ;-) Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl