Is there a way to determine if a script is waiting on stdin and cause the command to exit if detected?
Here's an example, the command I'm executing takes a long time to run, but it will also prompt for input before starting w/o a prompt. I want to know the command is actually doing something and not just waiting.
Provided the following script called ./demo
Is there a way to detect that read is waiting on stdin? Something like
failifwaitingonstdin | ./demo
Which would immediately return as soon as the read command was detected.
Folks have suggested programs like expect and yes. After digging through yes, I see how they're able to support this style of interaction. They're constantly using fputs to write 'y' to stdout. Instead of doing this infinitely, I can simply return an error as soon as fputs returns on a write to stdout.