Преимущества:
- можно передать данные через input stream.
- output можно получить как сразу целиком, так и частями (построчно, или произвольными кусками, по мере их доступности).
- Для доступа к частям используются итераторы (что для lua идиоматичнее колбеков как в Execute)
- опционально: output форматируется под заданную ширину
- доступен код возврата программы
- предусмотрена обработка ошибок
Executes a specified command, putting the specified text to it's input stream, and providing convenient access to the command's output/err. Syntax: obj = sh.piper(cmdline [,options]) cmdline: a string specifying the command to be executed options: a table with optional keys: - directory: a string specifying the working directory for the command - input: a string representing the text to be provided as input to the command - isOem: a boolean, if true then CP en-/decoding performed - linewrap: a number specifying the maximum width for each line of output obj: a table with the following keys: - all: a string containing all the output generated by the executed command - chunks: an iterator function that returns the output in raw chunks - lines: an iterator function that returns the output line by line - streamlines: an iterator function that returns the output line by line in a stream-like manner. It adds more data to each line as it becomes available. The iterator keeps returning the same line with more data until it is complete, and then adds a second `true` value to indicate completion. - ExitCode: an integer representing the exit code of the command (obtained from GetExitCodeProcess)