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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to call a menu script and redirect each option to a text file
# 1  
Old 09-04-2013
Wrench 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
# 2  
Old 09-04-2013
Please try something like this, as your question is not clear.

Code:
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


Last edited by learnbash; 09-04-2013 at 06:26 PM.. Reason: remove duplicate
# 3  
Old 09-04-2013
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
# 4  
Old 09-04-2013
Hello,
If you want to create an automate, you can follow this example:
Code:
$ mkfifo exchange

Code:
$ cat menu.sh
#!/bin/bash
 
while true
do
        echo "Valeur:"
        read f
        if [ "${f}" -eq "12" ]
        then
                echo "Bingo"
                sleep 2
                exit
        fi
done

Code:
$ 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.
Code:
$ ./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.
# 5  
Old 09-29-2013
I think I am not yet able to expain what i need.

Code:
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.

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Menu Driven Bash Shell Script with Default Option

Hi All, I have written a menu driven bash shell script. Current Output is as below: ------------------------------------- Main Menu ------------------------------------- Option 1 Option 2 Option 3 Option 4 Exit ===================================== Enter your... (3 Replies)
Discussion started by: kiran_j
3 Replies

2. Programming

Listing Option Menu Choices from Text File

Hello, I am starting up a tool and one of the initial steps is to select a site/location which is being read from a text file. Here is the text file contents: site1 site2 site3 Here is the code: #!/usr/bin/python from Tkinter import * (3 Replies)
Discussion started by: tattoostreet
3 Replies

3. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

4. Shell Programming and Scripting

Call one script option to other in shell script

HI Guys, My Script abc.sh 1) Checks 2) CA Scipt 3) CIA Script 0) Exit Enter Choice : Now if i select choice 2 then after finshed choice 2 wait for 40 min and run choice 3 what i can write in CA Scipt option: if then My Code : ... (3 Replies)
Discussion started by: pareshkp
3 Replies

5. Shell Programming and Scripting

sh file: READ (menu) but now run with option

I have a script which uses READ to detect choice of menu option...now I want to change the script without doing whole rewrite such that when user runs ./script.sh 5 it would execute menu option 5 rather than user running ./script.sh waiting for it to load and then pressing "5 enter" Is it... (1 Reply)
Discussion started by: holyearth
1 Replies

6. UNIX for Dummies Questions & Answers

What is a menu or command line option driven script?

i'm confused what this means. i was asked to design a menu or command line option driven script that reads out of a DB and displays info such as read_data.pl -u <user> -e <event> which would print commands run by <user>with the <event> in the db. any suggestions? i've been using... (2 Replies)
Discussion started by: kpddong
2 Replies

7. Shell Programming and Scripting

Call and redirect output of Oracle stored procedure from unix script

Hi, Can you assist me in how to redirect the output of oracle stored procedure from unix script? Something similar to what i did for sybase isql -U$MYDBLOG -D$MYDBNAME -S$MYDBSVR -P$MYDBPWD -o$MYFILE<< %% proc_my_test 8 go %% Thanks in advance - jak (0 Replies)
Discussion started by: jakSun8
0 Replies

8. Shell Programming and Scripting

script to show menu option & need to be autorun

hi i need to perform following task have to write script to display menu like 1) login as user1 2) login as user2 3) login as user3 4) go to shell script will be run through root user user1, user2 will be logged to specific thr account. if 4th option selected it must pass... (3 Replies)
Discussion started by: anup13
3 Replies

9. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

10. UNIX for Dummies Questions & Answers

Changing korn shell script text Menu colors?

Is it possible to change the color of text in a korn shell script Menu? I can change the color of session text through my telnet client but I want to be able to change color text in the Korn shell menu to highlight certain items. (6 Replies)
Discussion started by: darthur
6 Replies
Login or Register to Ask a Question

Featured Tech Videos