本文介绍了如何在whiptail文本框中显示命令输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

whiptail 命令有一个选项 --textbox,其描述如下:

The whiptail command has an option --textbox that has the following description:

--textbox <file> <height> <width>

第一个选项需要一个文件作为输入;我想在它的位置使用命令的输出.这似乎在 sh 或 bash 中应该是可能的.为了这个问题,假设我想在一个whiptail文本框中查看 ls -l 的输出.

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.

请注意,进程替换在whiptail 中似乎不起作用(例如,whiptail --textbox <(ls -l) 40 80 不起作用.

Note that process substitution does not appear to work in whiptail (e.g. whiptail --textbox <(ls -l) 40 80 does not work.

这个问题是对另一个stackoverflow问题的重新提问,技术上已经回答了.

This question is a re-asking of this other stackoverflow question, which technically was answered.

推荐答案

试试这个解决方法:

whiptail --textbox /dev/stdin 40 80 <<<"$(ls -l)"

Bash 通过创建自己的临时文件并将提供的字符串放入其中来处理 <<< 标准输入重定向.由于它是一个真实的文件,它应该是可查找的.但不能保证它总是这样工作:)

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 :)

这篇关于如何在whiptail文本框中显示命令输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 04:59