Cecil Westerhof <
Ce...@decebal.nl> wrote:
> Gerald Lester <Gerald...@KnG-Consulting.net> writes:
>
>> On 02/12/2018 04:26 AM, Cecil Westerhof wrote:
>>> I am thinking about writing a GUI around some command-line commands.
>>> Is there a way to put the output from a pipe command into a
>>> scroll-able window?
>>
>> Yes, read the following man/help/documentation:
>> From Tcl:
>> - open (pay attention to the section on pipes "|")
>> - fileevent (or chan event)
>> - maybe fconfigure
>> - read (read not gets)
>
> Why read not gets?
There is one other reason for 'read' vs. gets I forgot to mention.
'read' lets you control how much data you consume at a time. 'gets'
will continue absorbing data until it finds a line terminator (or runs
out of memory).
So if you were to expose a 'gets' based input to malicious actors, they
can generate an out-of-memory situation for you by feeding your input
with a huge amount of data with no line terminators.