I am wanting to create a menu that will list all the log files in a specific directory such as /apps/logs.
So it would be something like this:
#!/bin/ksh
print 'Select The Required Log File'
PS3='log? '
select choice in <this is to contain a list of files that are in a directory that would be populated using find /apps/logs>
If it means that a user should be presented with a menu that lists all log file from /apps/logs and then he wants to view 'em selectively then I think we could:-
1) find /apps/logs -type f
2) Number the files from find's output and present the user
3) At the time they are displayed populate them in an array
4) display user to enter choice and pull that choice from array.
So it would be something like this in ksh ( I havenot tried it..chk for syntax errors)
------------------------------------------------------
#!/bin/ksh
logcnt=0;
for logfile in `find /apps/logs -type f `
do
logarr[$logcnt]=$logfile
echo "$logcnt : $logfile"
((logcnt=$logcnt+1))
done
echo "Enter ur choice to view :\c"
read choice
cat "`cat ${logarr[$choice]}`"
-------------------------------------------------------------------
I havenot provided any kind of locking facility here to handle errors. It 's just an idea
Ygor,
Thanks for the info. It is almost what I am looking for.
I am needing a menu with some dynamic items from find and other static items.
$DYNAMIC_ITEMS is where i will use my find, etc. For now i just set it.
The $DYNAMIC_ITEMS will be run in a similar fashion but the others will need to be run differently.
I was trying to use select choice and case and for loop.
Everything with exception of Configuration, ALL, MENU,and Quit should be dynamically created.
I also can't get your code to work inside of a case statement. Any help would be appriciated!