Creating a menu from find

Hi

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>

any pointers would be most helpful.

Thanks

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

Try...

select choice in $(find /apps/logs -type f -name '*log*')
do
   [ $choice ] && view $choice
   break
done

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.

  1. This is with you code and the menu works.
DYNAMIC_ITEMS="fix_cron fix_ndd fix_sendmail.pid fix_serial fix_vftab ipmp.ksh new_bp_conf"
MENU_ITEMS="ALL CONFIGURATION $DYNAMIC_ITEMS MENU"
select CHOICE in $MENU_ITEMS
do
    [ $CHOICE ] && $ECHO $CHOICE
    break

done

Which produces :

 1) ALL
 2) CONFIGURATION
 3) fix_cron
 4) fix_ndd
 5) fix_sendmail.pid
 6) fix_serial
 7) fix_vftab
 8) ipmp.ksh
 9) new_bp_conf
10) MENU
POST INSTALL MENU:

The problem is that ALL items are run the same way, in this case $ECHO $CHOICE.

Here is my manual method:

#select CHOICE in Configuration uiss_test fix_cron fix_ndd fix_sendmail.pid fix_serial fix_vftab ipmp.ksh new_bp_conf ALL MENU Quit                                                                                                                       #do
#   case $CHOICE in
#   Configuration)  config;;
#   uiss_test)  config;$UISS_SCRIPTS_DIR/uiss_test;;
#   fix_cron)   echo fix_cron;;
#   fix_ndd)    echo fix_ndd;;
#   fix_sendmail.pid)   echo fix_sendmail.pid;;
#   fix_serial) echo fix_serial;;
#   fix_vftab)  echo fix_vftab;;
#   ipmp.ksh)   echo ipmp.ksh;;
#   new_bp_conf)    echo new_bp_conf;;
#   ALL)    echo ALL;;
#    MENU)  menu;;
#   Quit)  exit;;
#    *)  $ECHO "\nINVALID CHOICE:\n";;
#  esac
#done

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!