Ввод текста в Zenity

Я пытаюсь выполнить функцию удаления внутри поля ввода zenity. Я хотел бы знать, как я могу сохранить путь, указанный пользователем внутри поля ввода в переменной или как я могу его использовать. спасибо вот мой код

      #!/bin/bash
function Ddate() {
    zenity --info \
    --title "Date and Time" \
    --text "Today is $(date)"
}

function Dcalendar() {
    zenity --calendar \
    --title "Calendar" \
}

function Ddelete() {    
    zenity --entry \
    --entry-text "Ex: home/knoppix/" \
    --text "Enter a path" \
    --title "Delete" \
}

while true;
do
choice="$(zenity --height 275 --width 450 \
--list \
--title="Menu" \
--column="Function" --column="Description" \
    Date 'Display the actual date and time.' \
    Calendar 'Display an interactive calendar.' \
    Delete 'Let you delete a file.' \
    Exit 'To quit this script.')"

case $choice in
    Date) Ddate;;
    Calendar) Dcalendar;;
    Delete) Ddelete;;
    Exit) break;;

esac

done

1 ответ

Обычно, если вы хотите вставить данные в переменную из "zenity", вы можете попробовать этот пример:

      NAME=$( zenity --entry --text="type your name" )

if [ $? = 0 ] # check if the user click ok on the zenity form
then
    echo "Hello $NAME"
else
    echo "the user didn't click ok button"
fi

Надеюсь, это поможет.

Другие вопросы по тегам