(************************************************************ exec_script.ml Created : Sun Dec 14 10:05:38 2003 Last modified: Sun Dec 14 10:13:53 2003 Compile: ocamlc -dtypes unix.cma exec_script.ml -o exec_script # FTP Directory: sources/ocaml # ************************************************************) (** @author Takashi Masuyama *) let _ = let filename = "testscript.sh" in let output = open_out filename in output_string output "#! /bin/sh\n"; output_string output "echo hello\n"; flush output; close_out output; let cwd = Unix.getcwd () in let path = Filename.concat cwd filename in try Unix.chmod path 0o700; Unix.execv path [||] with Unix.Unix_error (m, f, _) -> prerr_endline (f ^ ": "^ (Unix.error_message m)) ;;