1

Как вывести окно, чтобы туда можно было ввести параметр?

1
  • @maza51, Если вам дан исчерпывающий ответ, отметьте его как верный (нажмите на галку рядом с выбранным ответом). 3 мар 2015 в 12:53

2 ответа 2

1

Установите пакет dialog:

This application provides a method of displaying several different types of dialog boxes from shell scripts. This allows a developer of a script to interact with the user in a much friendlier manner.

apt-get install dialog

Возможно потребуется установить еще и ncurses

После чего можно делать так:

#!/bin/bash
: ${DIALOG=dialog}
: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --title "INPUT BOX" --clear "$@"  --inputbox "Введите что-нть" 8 16 2> $tempfile

retval=$?

case $retval in
  $DIALOG_OK)
    echo "Result: `cat $tempfile`";;
  $DIALOG_CANCEL)
    echo "Cancel pressed.";;
  $DIALOG_ESC)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
  ;;
esac

Больше примеров можно найти в /usr/share/doc/dialog/examples/

0

Скорее всего вам подойдет read. Эта команда не выводит дополнительное окно, а просто ждет ввода в терминале и заносит введенную строку в указанную после read переменную.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.