How to display command output in a whiptail textbox

こ雲淡風輕ζ 提交于 2020-02-04 01:31:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!