How to include menu based options in Shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to include menu based options in Shell script?
# 1  
Old 05-27-2016
Debian How to include menu based options in Shell script?

Hi Friends,

I have a menu based tool which requires input/option to proceed further. How to make a shell script ?

eg: menu looks like

Get_data.sh
Code:
to continue (y/n) :


Here I need to key in "y" to proceed.

I want to prepare a script which should consider option y.

Last edited by RudiC; 05-27-2016 at 04:00 AM.. Reason: Added code tags.
# 2  
Old 05-27-2016
Not clear. Do you want to create a menu or do you want to supply input to an existing menu?

That "tool", is it a script or an executable binary? Can you modify it? Get_data.sh implies we are dealing with a shell script...

Please rephrase your request.
# 3  
Old 05-27-2016
I would like to run an " existing menu and input option " both using a shell script.
the menu based tool is a binary
# 4  
Old 05-27-2016
If you really only need to enter "y", then expect would be the tool of choice.

Unfortunately I may not post you a link to an example, because I'm not yet allowed to post URLs at the moment.
# 5  
Old 05-27-2016
You do don't ever need the third party expect brute-forcing tool to read input from the user.

Code:
printf "%s" "do something (Y/N)"
read -n 1 INPUT # To read one keystroke on bash

# If BASH isn't available, you can read a keystroke followed by enter key
read INPUT

# 6  
Old 05-27-2016
If you just want to read an answer from your user, use Coronas Code.

As what I understood, you want to control another program - and you want to automate that - and you don't have the possibility to change the source of that code, then expect may be a last possible solution.

Here's the example, if you needed(German website. The example itself should should be no problem though.

Automatisiertes Installations-Script / Shell (VMware) • debianforum.de

Last edited by stomp; 05-27-2016 at 02:29 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

2. Shell Programming and Scripting

Automate the menu options using shell script

I have a menu option which will look as follows Select a menu option 1.change password 2.login as root user 3.show system version 4.quit Select> 1 please enter the new password: unix reenter the new password: unix press any key to enter (then displays again the menu options to enter the... (4 Replies)
Discussion started by: shivakumar6g
4 Replies

3. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 Replies

4. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

5. Windows & DOS: Issues & Discussions

Windows Advanced Options Menu

I dual boot between Windows XP and Linux Mint. I am trying to get the Windows Advanced Options Menu to show up. Normally you would press f8 to make this happen when your computer is booting. With a dual boot it makes it way more complicated. If you press f8 when your computer first starts it does... (3 Replies)
Discussion started by: cokedude
3 Replies

6. UNIX for Dummies Questions & Answers

[solved] Script creation (how to include options in the script)

Hi guys i have written a script which takes the options given to him and execute itself accordingly. for example if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies

7. Homework & Coursework Questions

Menu Driven Shell Script which accepts1 to 5 options

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) Write a Menu Driven Shell Script which accepts1 to 5 options and performs the following actions for... (1 Reply)
Discussion started by: vaghya
1 Replies

8. UNIX for Dummies Questions & Answers

proceed through a menu-based program with a script?

I am trying to figure out a way to proceed through a menu-based program in UNIX with just one command to execute several steps. Is this possible? From the command prompt I would normally type the name of the program, 'disk_analysis' to start the program and bring up its menu. I would then... (4 Replies)
Discussion started by: nichola$
4 Replies

9. Shell Programming and Scripting

menu.lst, boot options?

Hi all, I would like to have some details on menu.lst!! the reason is ,if i am trying to add my own boot option where do i need to add it? is it in menu.lst only or elsewere(am referring to unix os) because i tried adding a unique boot option and it was not reflected when the system booted?... (8 Replies)
Discussion started by: wrapster
8 Replies

10. UNIX for Dummies Questions & Answers

Help needed with menu options

I'm programming a menu for an intro to unix class and am hung up on 2 required options. One has to exit from unix. The other has to get a command prompt by using one of the menu choices, then return to the menu via CTRL-D. below is my code #!/bin/ksh #Jimmy's happy menu mesg y msg="ON"... (2 Replies)
Discussion started by: sanitywonko
2 Replies
Login or Register to Ask a Question