Results 1 to 1 of 1
Hey Guys, Can someone help me turn the following standard txt menu that inputs menu options via data from a file called 'filename'...
Code:
prompt_location() {
file_location="${root}/filename"
iter=1
export iter
...
- 09-24-2008 #1Just Joined!
- Join Date
- Sep 2008
- Posts
- 2
Converting standard txt menu to dialog menu with data input from array.
Hey Guys, Can someone help me turn the following standard txt menu that inputs menu options via data from a file called 'filename'...
Code:prompt_location() { file_location="${root}/filename" iter=1 export iter echo "Please choose a location/site:" cat $file_location | while read line do sname=`echo $line | cut -d':' -f 1` echo "("$iter")" $sname iter=`expr $iter + 1` done echo -n "[1] " read snum max=`wc -l $file_location | cut -d ' ' -f 1` if [ $snum -le $max ] then myline=`cat $file_location | head -$snum | tail -1` site_name=`echo $myline | cut -d':' -f 1` site_dns1=`echo $myline | cut -d':' -f 2` site_dns2=`echo $myline | cut -d':' -f 3` site_tz=`echo $myline | cut -d':' -f 4` clear else [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE echo 'Invalid selection' [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL prompt_location fi }
into a dialog menu like so (from clonezilla project), but isntead of inputing menu options from directory names, bring the menu options in from the input file called 'filename':
Menu like so:Code:get_existing_parts_image() { # show existing partitions images so that user can choose then return chosen to file ANS_TMP local ANS_TMP=$1 local tgt_file local ASK_IMGNAME=1 local TMP=`mktemp /tmp/ocs.XXXXXX` trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT numfiles=`ls $imagedir 2> /dev/null | wc -l` numfiles=`expr $numfiles + 0` filelist="" numfiles=0 for file in `ls $imagedir 2> /dev/null`; do # only directory ..., not file [ ! -d "$imagedir/$file" ] && continue [ ! -f "$imagedir/$file/parts" -a ! -f "$imagedir/$file/disk" ] && continue fileinfo=`ls -lhd $imagedir/$file | awk '{ print $6"_"$7; }'` if [ -f "$imagedir/$file/parts" ]; then fileinfo=$fileinfo"_"$(tr ' ' _ < $imagedir/$file/parts) elif [ -f "$imagedir/$file/disk" ]; then fileinfo=$fileinfo"_"$(tr ' ' _ < $imagedir/$file/disk) fi filelist="$filelist $file $fileinfo" numfiles=`expr $numfiles + 1` done if [ $numfiles -gt 0 ]; then if [ $numfiles -lt $MAX_DIALOG_HEIGHT ]; then height="$numfiles" else height="$MAX_DIALOG_HEIGHT" fi while [ "$ASK_IMGNAME" -ne 0 ]; do $DIA \ --backtitle "$msg_nchc_free_software_labs" \ --title "$msg_nchc_clonezilla" \ --menu "$msg_choose_the_image_to_restore:" 0 $RESTORE_DIA_WIDTH \ $height $filelist 2> $TMP tgt_file="$(cat $TMP)" if [ -z "$tgt_file" ]; then $DIA --backtitle "$msg_nchc_free_software_labs" --title "$msg_nchc_clonezilla" \ --msgbox "$msg_you_must_input_filename!\n$msg_please_do_it_again!" 0 0 else ASK_IMGNAME=0 fi done else [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE echo "No disk or partitions image directory is found in $imagedir! $msg_program_stop!!!" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL exit 1 fi [ -f "$TMP" ] && rm -f $TMP # return the valule echo $tgt_file > $ANS_TMP } # end of get_existing_parts_image


Reply With Quote