Sponsored Content
Top Forums Shell Programming and Scripting Script to call a menu script and redirect each option to a text file Post 302850445 by disedorgue on Wednesday 4th of September 2013 07:22:28 PM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

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

8. 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

9. 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

10. 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
menu_opts(3X)															     menu_opts(3X)

NAME
menu_opts - set and get menu options SYNOPSIS
#include <menu.h> int set_menu_opts(MENU *menu, Menu_Options opts); int menu_opts_on(MENU *menu, Menu_Options opts); int menu_opts_off(MENU *menu, Menu_Options opts); Menu_Options menu_opts(const MENU *menu); DESCRIPTION
The function set_menu_opts sets all the given menu's option bits (menu option bits may be logically-OR'ed together). The function menu_opts_on turns on the given option bits, and leaves others alone. The function menu_opts_off turns off the given option bits, and leaves others alone. The function menu_opts returns the menu's current option bits. The following options are defined (all are on by default): O_ONEVALUE Only one item can be selected for this menu. O_SHOWDESC Display the item descriptions when the menu is posted. O_ROWMAJOR Display the menu in row-major order. O_IGNORECASE Ignore the case when pattern-matching. O_SHOWMATCH Move the cursor to within the item name while pattern-matching. O_NONCYCLIC Don't wrap around next-item and previous-item, requests to the other end of the menu. RETURN VALUE
Except for menu_opts, each routine returns one of the following: E_OK The routine succeeded. E_SYSTEM_ERROR System error occurred (see errno). E_POSTED The menu is already posted. SEE ALSO
curses(3X), menu(3X). NOTES
The header file <menu.h> automatically includes the header file <curses.h>. PORTABILITY
These routines emulate the System V menu library. They were not supported on Version 7 or BSD versions. AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. menu_opts(3X)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy