Shell script using an interactive command

Hello experts,

I have a to write script for monitoring, the script would use a command and I plan to write the script as follows

while true
do

command -arg

sleep 2

clear
 
done

The output would be set up on a screen for monitoring. However the issue is that the command used in the script is an interactive command

command v7.9.1 - available servers - status at 17:40:25


command output


Which project? ('q' to quit): q

Is there a way I can pass the q command or redirect it to the command,so that i may use it to write a wrapper.

Thanks In advance

Try TCL's expect.

If it is a straightforward command, maybe try:

echo "q" | command

If it asks multiple times or reads in a strange way, maybe try:

yes "q" | command

If it is a Shell script, modify it to take a parameter on the command line which disables the question.