dongxuan8227 2019-05-20 08:29
浏览 70

我需要以什么格式导出lynis才能保留彩色输出?

I have successfully exported lynis' output in terminal to a .txt file but when I tried to show it in my laravel modal, the colour codes become boxes of unknown characters (like when you send chinese text but its not supported by the device.

I have tried exporting it to .odt, .rtf and so on but the result is the same.

what I expected (the [done] is in green)

- Checking profiles...                                      [ DONE ]

here's the actual result:

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

this is what I run in my ansible to get the output of lynis

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

this is what I use in php to show the contents of the .txt

return nl2br(file_get_contents($path));

I checked the exported results in vim and it also shows

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

I know that .txt can't have coloured texts. so the question is which format should I use or how do I format it so that it can be shown with colours

  • 写回答

1条回答 默认 最新

  • douyiavxxh02727 2019-05-20 10:26
    关注

    I found an answer.

    I use ansible to install epel-release and pip (the hosts are centos) then I install ansi2html via pip and do

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

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)