Presentation is loading. Please wait.

Presentation is loading. Please wait.

“Shell Scripting” with SML

Similar presentations


Presentation on theme: "“Shell Scripting” with SML"— Presentation transcript:

1 “Shell Scripting” with SML
Kevin Jones Friday, May 13, 2005

2 Target Functionality Piping between process Branched pipes
Echoing output from a a process to a file or standard out along with the next process Basic file handling Simplified environment and argument handling Allow all exceptions without to be caught outside of the structure

3 Changes in CML Added functionality to Unix structure signature UNIX = sig type proc val executeInEnv : string * string list * string list -> proc val execute : string * string list -> proc val pidOf : proc -> Posix.Process.pid val pipeOf : proc -> Posix.IO.file_desc * Posix.IO.file_desc val streamsOf : proc -> TextIO.instream * TextIO.outstream val mkPipe : string -> TextIO.instream * TextIO.outstream val reapEvt : proc -> Posix.Process.exit_status CML.event val reap : proc -> Posix.Process.exit_status val kill : proc * Posix.Signal.signal -> unit end

4 SCRIPTML Signature signature SCRIPTML = sig type environment type file datatype pipe = Pipe of (string * string list * environment * bool * (string * bool) option) list * output and output = Branch of pipe list | StdOut | FileAppend of string | FileOverwrite of string val start : string * string list * string list * (string * string list * environment -> unit) -> OS.Process.status val set : environment * (string * string) list -> environment val get : environment -> string -> string option val makeFile : string -> file option val openFile : string -> file option val touchFile : string -> bool val closeFile : file -> unit val readFile : string -> string list val write : file -> string -> unit val pipe : pipe -> unit end;

5 pipe datatype Complete path to the program Arguments for the program
The environment to run it in If it should be echoed to standard out A file the output would be echoed to and if it should overwrite the file if it exists

6 Argument handling Arguments can be read and put in the environment
testProgram -var1=value1 -var2 value2 All of the arguments get passed to the function even if they are added to the environment

7 Demonstrations

8 Possible Improvements
Some programs seem to not work correctly, notably grep and maybe ls Special cases could be made to handle useful programs that do not work Add support for stream processing functions between processes Thread safety in output to files in pipes


Download ppt "“Shell Scripting” with SML"

Similar presentations


Ads by Google