问题
The whiptail
command has an option --textbox
that has the following description:
--textbox <file> <height> <width>
The first option requires a file as input; I would like to use the output of a command in its place. It seems like this should be possible in sh or bash. For the sake of the question, let's say I'd like to view the output of ls -l
in a whiptail textbox.
Note that process substitution does not appear to work in whiptail (e.g. whiptail --textbox <(ls -l) 40 80 does not work.
This question is a re-asking of this other stackoverflow question, which technically was answered.
回答1:
Try this workaround:
whiptail --textbox /dev/stdin 40 80 <<<"$(ls -l)"
Bash handles <<<
stdin redirection by creating its own temporary file and putting the supplied string into it. Since its a real file, it should then be seekable. But no guarantees that it will always work that way :)
来源:https://stackoverflow.com/questions/23089988/how-to-display-command-output-in-a-whiptail-textbox