How to automate user menu selections?

Hello all, I am sort of new to Shell programming and to this forum. I want to create a script that auto selects menu options.

lets say I have a menu.

MAIN MENU
1.) opt1
2.)opt2
3.)opt3

I want the script to automatically select option 1.

This is a very vague request... Is this a homework assignment?

What operating system are you using?

What shell are you using?

Are you saying that you have a script that can process one of three options, and if no option is specified when the script is invoked it should default to the 1st option?

What is supposed to happen when each of these three options is chosen?

Why have three options if your script is only supposed to process the 1st option?

Nope is not for homework.
I am using linux ksh.

The script displays a menu to the user. the user has to select an option. then the it shows a submenu. basically what I am trying to do is to automate responses, as i have to do this many times a day, same responses.

You have lots of options; two obvious ones are:

  1. make a copy of the script and modify it to just execute the options you want,
  2. use a printf command to pipe the script the responses it will need to select the options you want.

could you provide an example of how I would pass the options using printf?

unfortunately i don't have access to editing the original script, :confused:

printf 'Response to select 1st menu option\nResponse to select submenu option\n' | script_name

How do you run the script with the menu options if you can't read it?

There is two original scripts already written. the first one which i have to run with sudo privileges that displays the menu. this first script then sends variables and options chosen to a second massive script which contains several different functions.

I did a tail -f on the log of the second scrip which is the one that actually gets the task done while i selected the options and ran my task. I am able to read this and i know the functions that get called. Eventually i would want to write my own script but with only the functions that i need. Hope this made some sense. thank you for the help Don.