lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Dec 7, 2013 12:22 AM, "Daurnimator" <quae@daurnimator.com> wrote:
>
> On 6 December 2013 09:09, Alexander Schulz <aiqpost@yahoo.com> wrote:
> > i want to create a script with lua that reads from a pipe and allows to read input from the user terminal.
> >
> > Example: history -n | tail -n 10 | my_script
> >
> > In this case is io.stdin a file descriptor to the pipe.
> > How can i get now in lua a file descriptor on the current terminal?
>
> io.stdin is what you want; you can use the :lines() iterator:
>
> for line in io.stdin:lines() do
>     print(line)
> end

In the original question, stdin is already redirected from the standard output of "tail". What Alexander wants is to have an explicit input from console, even if the standard input is redirected.