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. Quote:
option 1.1) should give the option to user to choose one file, whose content user wanna see. I can implement this as a separate option. But I want to implement this under option 1. Can this be happen? I tried using some but failed. Here is how my script is working. Code:
#!/usr/bin/ksh Thanks, |
Something along the lines of this code snippet might help:
Code:
case $choice in |
Hi I made some enhancement in the code. But its not helping out.
Code:
case $choice in What exactly I wanna do: 1. User enter to view the log files. 2. Entered the menu number. Menu shows the list of files. 3. Now he wanna see the contents of a particular file. 4. There should be an option which make him capable to enter the file name, so that he can see the contents of file. 5. If he doesn't enter the file name. It should return back to menu. Without saying anything. |
Have you perhaps tried looking at the 'select' command? It would seem trivial to use it as the main menu operator and also to then apply a smaller sub-select on the files you are interested in.
|
Quote:
Your find command might be the problem, though. It specifies a directory to search in (/test/LogFiles), which your original version didn't do, and if that is not your current directory, the option 2.1 code would not find it. Changing: Code:
if [ ! -z "$filename" ] Code:
dirname="/test/LogFiles" |
Hi all, thanks for you help.
I solved it like this: Code:
echo View Log files; |
Well I am curious as to what errors you are anticipating from the first find that are not an issue in the second?
Also, you might be interested in looking up the -printf option for find so you can throw away the useless awk. If you want to be more clever, you could store the output in an array and use it in a select, this way you do not rely on the user to type the filename in correctly :) have you also had a close look at your last find command? Code:
find /backup/test1/LogFiles/$filename -type f ! -name ".*" -exec more {} \; |
Quote:
about find, I'm not able to understand, I just used them and made them work as per requirement. I'd love to learn more. plz tell :) |
Ok ... I had a bit of a play and you will need to change to how you like it.
Things to note: Find used assumes that there are no sub directories and that filenames do not contain whitespace Code:
#!/bin/bash Hopefully it will give you some ideas. |
All times are GMT -5. The time now is 03:05 PM. |