proceed through a menu-based program with a script?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers proceed through a menu-based program with a script?
# 1  
Old 09-24-2008
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 enter '7' to choose an input and output file and then manually type the location of the input file for example,"H:/data/input.txt"; Then I would enter '2' to execute the analysis.

I tried just listing them sequentially like so,

disk_analysis; 7; H:/data/input.txt; 2

but the program only opens and never even executes the first step. Is there some way to have it wait a bit for the menu to show up before sending each next command?

Thanks

Last edited by nichola$; 09-24-2008 at 06:11 PM..
# 2  
Old 09-25-2008
Combine them in functions, thus, when you type diskSpace, the script will execute diskSpace() function.
# 3  
Old 09-25-2008
pardon my ignorance, but what would a function like that look like if say I wanted to wait 5 seconds between each command.

also, the reason I want to run everything in one command is because I'll be making a system call to unix from another c++ program and I was hoping to have the unix program run from this system call instead of stopping everything to manually pull up a window and navigate through the menu. If this is too crazy an idea let me know and i'll save my energy!
# 4  
Old 09-25-2008
sounds like expect might be what you want: Expect - Expect - Home Page
# 5  
Old 10-03-2008
I checked out expect. that would be a great program to try for anyone else trying to do the same thing. I found out by searching the source code that there was a hidden option to run in batch mode. Thanks for the input.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies

2. Programming

I'm implementing menu config based on curses terminal

I'm implementing menu config based on curses terminal. for example: $ xmake --menu It automatically gets the options in the project to generate the menu configuration interface to implement the interactive configuration, like make menuconfig based Kconfig example: $ git clone... (0 Replies)
Discussion started by: waruqi
0 Replies

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

4. Shell Programming and Scripting

Script to Proceed to the Next IP if the current IP hangs

Hi there, Say I have a list of IPs, I am running scripts on them. If the process hang. I want to continue with the rest of the IPs. 10.11.1.1 10.11.1.2 10.11.1.3 10.11.1.4 10.11.1.5 10.11.1.6 <-- Process Hangs here 10.11.1.7 10.11.1.8 10.11.1.9 10.11.1.10 10.11.1.11 10.11.1.12 ... (11 Replies)
Discussion started by: alvinoo
11 Replies

5. Shell Programming and Scripting

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 to continue (y/n) : Here I need to key in "y" to proceed. I want to prepare a script which should consider option y. (5 Replies)
Discussion started by: suresh3566
5 Replies

6. Shell Programming and Scripting

Program based on hostname

Hi Can you help me get the script for below requirement. when i run below script ./script QM hostname script should be working in below here inputs are QM and hostname by taking inputs it should work like below QM=$1 if QM name ends with 1 $4 should be 51431 ends with ... (4 Replies)
Discussion started by: darling
4 Replies

7. Programming

C program - convert values based on the position

Hey! I'm new to C. I need to covert certain values using C. please see the below. I have figured out the logic to do it. Please provide some hints to do this with C Logic: If first position of POS = 0, shift POS to the left one byte. If third position of POS = 0, move spaces to third... (1 Reply)
Discussion started by: rocker_me2002
1 Replies

8. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

9. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

10. UNIX for Dummies Questions & Answers

Unix Menu program

I am tasked with creating a front end 'menu' program where the users will type '1' to do this command or '2' to do that command. I have found some stuff that I can copy to do that but it looks too flimsy to roll out in a production envirionment. I was wondering if you guys might know of a more... (4 Replies)
Discussion started by: hedrict
4 Replies
Login or Register to Ask a Question