Reading keyboard when stdin is redirected

As part of a course on Computing, I am trying to create a cut down version of GNU more. I need it to read the keyboard when stdin is redirected at the end of a pipeline. This happens when more outputs a screen full and prompts the user to scroll the screen.

The data displayed by more is read from its standard input, which in a command like foo | more comes from the standard output of foo. But more also reads directly from the terminal (for example, /dev/tty) to process user input for things like scrolling.

Thanks, I will open /dev/tty and read from that in the python version of my programme.

FYI there’s a program called “less” that is better than “more”. Apparently there are several makers of less: search. Mine is from 2026 by Mark Nudelman.

But this can be a good exercise in programming if that’s what you want to do. :slight_smile:

Yep. This is “part of a course”, so that is the goal, and I agree, it’s a great exercise.