Чтение со стандартного ввода и передача следующей команде

Я сделал следующие шаги при решении той же проблемы

  1. Установите VcXsrv для Windows и запустите его.
  2. Откройте bash в Windows и запуститеecho "export DISPLAY=:0" >> $HOME/.bashrc
  3. для изменений файла .bashrcдля запуска добавленияsource $HOME/.bashrc
  4. после этого вы можете запустить terminator -uи использовать его
1
09.12.2019, 15:34
1 ответ

Команда read устанавливает переменные bash, но не выводит на стандартный вывод.

напр. поместите stdout в файл Nothing1 и stderr в файл Nothing2, и вы ничего не увидите в этих файлах (с или без -s arg)

read 1>nothing1 2>nothing2 
# you will see nothing in these files (with or without -s arg)
# you will see the REPLY var has been set
echo REPLY=$REPLY

Итак, вы, вероятно, захотите сделать что-то вроде:

read -s pass && echo $pass |openssl base64 -e
# Read user input into $pass bash variable.
# If read command is successful then echo the $pass var and pass to openssl command.

из команды чтения ВСТРОЕННЫХ КОМАНД ОБОЛОЧКИ man bash:

read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name...]
          One  line  is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, and the first word is
          assigned to the first name, the second word to the second name, and so on, with leftover words and their intervening  separators  assigned
          to  the  last  name.  

    -s     Silent mode.  If input is coming from a terminal, characters are not echoed.

    If  no  names  are supplied, the line read is assigned to the variable REPLY. 
0
27.01.2020, 23:55

Теги

Похожие вопросы