Make my script press buttons

I am having some problems trying to come up with way that my script can press <enter> for me.

I am surrounded by people who are not UNIX friendly, and I want my script to push Enter for me, without bothering the user to hit it.

Is that possible?
maybe with stty or something?

Been racking my brain on this, but can't figure it out. Any help is appreciated.

What is waiting for the <enter>?

echo "" | program-that-is-waiting-for-enter

or

program-that-is-waiting-for-enter <file-that-only-contains-a-newline

or

tell robotic-arm
     extend
     rotate left 90%
     down
     up
     rotate right 90%
     retract
end

well nothing is actually waiting for it.

I have a huge "select do case" statement. and each time after chossing one of the options, I want to clear the screen and automatically hit <enter> again to show the select options.

kinda lame, and not exactly required, but I am sure the end user will be much happier with it.

so I am trying to put this at the end of each case choice.

:slight_smile: that robotic arm would be cool too, but I don't have a spare lying around :slight_smile:

Do you mean ksh's select? If so that is the thing that is waiting for <enter>.

I thought the menu was always displayed before the prompt....

i guess the PS3 prompt is waiting.

PS3="Select the item number:"

because in a select command it just sits and wait for you to choose, so i want it to automatically hit <enter> right when it gets back to the PS3 prompt after completeing the previous selection. This way it displays the full list of choices again.

Then do a break and get out then do the loop again...

while true
do
        PS3=......

        select ....... in .....
        do
               case "$REPLY" in ....
               ....
                      my long running thing
                      break;
               ....
               esac
        done
done

This does display my options again for me, but how do I get out of the big loop now?

previously my lastcase choice was

"Exit") break;;

but now that too kicks me right back into my select options

Have another flag, instead of "while true" have "while test "$RUNNING" = "1"" or similar.... set the flag beforehand, and set it to zero when you want to exit.

Or, depending on your script, you could really call exit, and if you had cleaning up to do, put it in a trap 0 function.

wow, I guess these 10 hour days are getting me, I missed the simple use of a while loop.

thanks so much porter

while test $RUN = 1
...
      "Exit") RUN=0
              clear
              break;;