Script to call a menu script and redirect each option to a text file

Hello,

I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file.

For example;-
In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output to xyz.txt

Could you please help me on this

Thanks

Please try something like this, as your question is not clear.

printf "ENTER UR CHOICE==> "
read ch;
case $ch in
1) sudo su - user1 ;;
2) sudo su - user2 ;;
3) sudo su - user3 ;;
4) break ;;
*) printf "";
   printf "INVALID OPTION SELECTED " ;
   printf "";;
esac

I want to design a new script xyz call MENU.sh and don't want to give the choice manually.
for example to select option from a text file that contains

2
3
4
5
9
10

and redirect these outputs to a text file

Hello,
If you want to create an automate, you can follow this example:

$ mkfifo exchange
$ cat menu.sh
#!/bin/bash
 
while true
do
        echo "Valeur:"
        read f
        if [ "${f}" -eq "12" ]
        then
                echo "Bingo"
                sleep 2
                exit
        fi
done
$ cat menu2.sh
#!/bin/bash
 
for i in {1..15}
do
        read f
        if [ "$f" = "Valeur:" ]
        then
                echo "$f $i" >&2
                echo $i
        fi
        if [ "$f" = "Bingo" ]
        then
                echo "$f" >&2
                exit
        fi
done

I have redirect echo to error (>&2) otherwise we don't see nothing.

$ ./menu.sh <exchange | ./menu2.sh >exchange
Valeur: 1
Valeur: 2
Valeur: 3
Valeur: 4
Valeur: 5
Valeur: 6
Valeur: 7
Valeur: 8
Valeur: 9
Valeur: 10
Valeur: 11
Valeur: 12
Bingo

But, this code work if in menu.sh, you don't use the -p option of the read commande.

Best regards.

I think I am not yet able to expain what i need.

MENU.sh output
  ================================================== ==
         1. BALANCE_PREPAGO
         2. CAMPAGNA
         3. Capabilities
         4. Chordiant
         5. CSAV
         6. CUADRO_MINUTOS_MIERCOLES
         7. CuVa
         8. DAILY
         9. DEVICES
         10. EXTRACCION_COMISIONES
         11. Wales
         12. INDICATORS
         13. INDICADORES_NUEVO
         14. INFORME_EMPRESAS_EJECUCION_VIA_SR
         15. LOGISTICS
         16. MARKETING_CONTRATO
         17. MM4M
         18. OPERACIONALIZACION_TELE2
         19. RECOMENDADOR_TARIFAS
         20. RED
         21. REINGENIERIA_INDICADORES
         22. SEGMENTACION_DE_ATENCION
         23. SIEBEL
         24. TARIFICACION_PREPAGO_DIAS [4-12]
         25. TELE2
         26. TELE2_ABALON
         27. UNIVERSO_IRIS
         28. WAMA
  -------------------------------------------------- -----------------
         0. Change day consultation
         X. Exit
  Consultation Date: YYYYMMDD
=====================================================================================
if i select option 1

it will give following output.

ENDED OK 33
ENDED NOTOK 1
EXECUITING 13
=====================

Now i do not want to select options one by one
and design anathor script menu2.sh that will call MENU.sh select option one by one and show me the output.