【问题标题】:into what format do I have to export lynis to in order to retain colorized output?为了保留彩色输出,我必须将 lynis 导出为什么格式?
【发布时间】:2019-05-20 08:29:58
【问题描述】:

我已成功将 lynis 在终端中的输出导出到 .txt 文件,但是当我尝试在我的 laravel 模态中显示它时,颜色代码变成了未知字符框(例如当您发送中文文本但它不受设备。

我尝试将其导出为 .odt、.rtf 等,但结果是一样的。

我所期望的([done] 为绿色)

- Checking profiles...                                      [ DONE ]

这是实际结果:

[2C- Checking profiles...[37C [ [1;32mDONE[0m ]

这是我在我的 ansible 中运行以获得 lynis 的输出

./lynis audit system > /var/log/{{ inventory_hostname }}-lynis.txt

这是我在php中用来显示.txt的内容

return nl2br(file_get_contents($path));

我在vim中检查了导出的结果,它也显示了

[2C- Checking profiles...[37C [ [1;32mDONE[0m ]

我知道 .txt 不能包含彩色文本。所以问题是我应该使用哪种格式或如何格式化它以便可以用颜色显示

【问题讨论】:

标签: php jquery laravel


【解决方案1】:

我找到了答案。

我使用 ansible 安装 epel-release 和 pip(主机是 centos)然后我通过 pip 安装 ansi2html 并执行

./lynis audit system | ansi2html > /var/log/{{ inventory_hostname }}-lynis.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 2020-07-17
    • 2013-09-21
    • 2021-02-22
    • 2021-01-31
    相关资源
    最近更新 更多