Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE Arguments = SysArgs.Arguments; TYPE Stream = POINTER TO StreamRec; TYPE StreamRec = RECORD (Streams.StreamRec) END;
PROCEDURE Open(VAR list: Streams.Stream); PROCEDURE Next(list: Streams.Stream); PROCEDURE Close(VAR list: Streams.Stream; VAR arglist: Arguments);
Open opens list for the first argument (write-only). The returned stream is of type UnixArgLists.Stream. Next extends the argument list and opens for the next argument. Close is to be called instead of Streams.Close to get the argument list.
Argument lists of SysArgs are untraced and therefore allocated by UntaggedStorage.New. Thus, they have to be explicitly deallocated by UntaggedStorage.Dispose.
PROCEDURE ExecShell(cmd: ARRAY OF CHAR); VAR list: Streams.Stream; arglist: SysArgs.Arguments; BEGIN UnixArgLists.Open(list); Write.StringS(list, "sh"); (* command name *) UnixArgLists.Next(list); Write.StringS(list, "-c"); UnixArgLists.Next(list); Write.StringS(list, cmd); UnixArgLists.Close(list, arglist); SysProcess.Exec("/bin/sh", arglist); UntaggedStorage.Dispose(SYSTEM.VAL(Types.UntracedAddress, arglist)); END ExecShell;
Oberon || Library || Module Index || Search Engine || Definition || Module