I am looking to build dynamic menu (named: lookup.sh) that reads a pipe delimited file for input.
for example, contents of input.txt could be:
I want the menu look like:
then if you choose option #1, it would cat pass_user1_srv1.txt to provide the password.
the key thing I am trying to accomplish is that I don't want to modify lookup.sh when i add a new option. i want to go to the input.txt file and add a line to that and it will be read in the next time lookup.sh is run.
will a bash array work? I am not too familiar with them.
Any ideas?
Any help would be greatly appreciated!
Chris
Last edited by Scrutinizer; 10-05-2016 at 07:32 PM..
Reason: code tags
If you do use a select loop, remember that you will need to use break to get out of the select loop. I try to avoid break everywhere else because it can be ambiguous as to which loop is being stepped out of.
If you do use a select loop, remember that you will need to use break to get out of the select loop. I try to avoid break everywhere else because it can be ambiguous as to which loop is being stepped out of.
Just my two-penneth-worth,
Robin
Hi Robin,
The command:
should break out of the innermost N (1 if N is not specified) enclosing for, while, until, and (in shells that implement select loops) select loops. You get varying behavior if you try to break out of more loops than you are currently in OR if you try to break out of a loop invoking a function using a break command inside that function's defining text, but if you're writing portable code you just shouldn't attempt to do either of those things.
Is there some other issue with break that has caused you problems?
Note that you can also exit a select loop by it hitting EOF on the file from which it is reading. So, if you are reading from a keyboard, you can add a choice to the selection list that is something like Enter ctl-D to exit when done if you want to avoid using break in a select statement. (But, it would usually be a good idea to add a break associated with that label in case the user enters the number associated with that selection instead of following directions and hitting ctl-D. ) Or, you can set PS3 with something like:
and avoid that possible confusion.
Hi guys, i would like to create a program that allow user to show the information of certain thing such as network card.
I would like the menu to be dynamic, for example:
my computer system have 2 network card inserted at the moment, therefore the menu will have 2 choice for the user.
eth0... (12 Replies)
Hi,
I got a requirement to automate the process.
We have SLA files, there are some 80 SLA files comes from 1.30pm - 5.30pm.
I was asked to write a script to check for the SLA files in the load directory, if the files come then we got to send the mail to the group, if the mails doesnt come... (1 Reply)
I need to create a dynamic drop down menu which is populated by entries such as;
htdocs/client1/index.php
htdocs/client2/index.php
htdocs/client3/index.php
htdocs/client4/index.php
etc.
So htdocs/client*/index.php
Is this possible?
I know how to do this using normal arrays, but not... (2 Replies)
How do I assign values to reference variables?
I am assigning a variable name to --> $user_var
Then I am trying to change its underlying variable value by
$((user_var))=$user_value .. its failing,,
Please let me know if there is a way to do this dynamically..
FileA.props... (5 Replies)
Hi there,
I am trying to figure out a way to combine multiple sources with different data on a single file, and I am trying to find the best way to do it.
I have multiple files, let's say A, B, C and D. A has a field in common with B, B has a field in common with C, and C has a field in... (2 Replies)
I'm working on a menu to read folders in as menu selections then CD to the selected folder and display the contained files as menu selections for execution.
I'm using the following to read in the file list but I get lost after that.
I only read in files that begin with CAPs. The problem is... (3 Replies)
Hi all
is menu driven by SELECT can be a dynamic ?
My requirement is that i want SELECT to be created on run time not predefine . The select should be created as per the no of
words in a file
thanks in advance
rawat (2 Replies)
what is a flat file in unix?
i have to import a unix flat files from windows based programme.
my question is not to export from unix but only to import from windows only.
how to build that flat files?
how to create export to windows
how to import from windows (3 Replies)
Hello all,
I'm developing a deployment script at work and at one point it would need to display something like this:
Which version of ADMIN would you like to deploy?
1) 1.0.0 (store1, 10 Jan 2004)
2) 1.0.1 (store1, 20 Jun 2004)
3) 1.0.2 (store1, 15 Jul 2004)
Select a version :
I know... (5 Replies)