Есть ли способ конвертировать вывод bash в html? например, если у меня был некоторый раскрашенный вывод в bash (что-то вроде htop), как я могу преобразовать его в html-теги ... (что-то вроде этого: <p style="color: red">some text</p>
)linux shell output to html
11
A
ответ
19
9
Да, вам нужно передать результат с помощью инструмента ansi2html.
3
Без какой-либо красивой печати самое простое, что вы всегда можете сделать, - это избежать всего, что нужно ускользнуть, и обернуть основную оболочку HTML (должно быть допустимо минимальное HTML5). Например, задержите fastesc: http://raa.ruby-lang.org/project/fastesc/ и заверните его в оболочку HTML.
Если вы хотите сохранить магию ANSI, то вам нужно преобразовать, что в HTML, возможно, с http://ansi-sys.rubyforge.org/
А потом сделать что-то вроде этого, в зависимости от ваших потребностей:
require 'ansisys'
def ansi_escape(string)
terminal = AnsiSys::Terminal.new
terminal.echo(string)
terminal.render
end
def to_html(string)
%Q{ <!DOCTYPE html>
<title>Converted to html</title>
<pre>
#{ansi_escape(string)}
</pre>
}
end
Смежные вопросы
- 1. получить jquery output to html output
- 2. Pandas Pivot output to html
- 3. Linux/OpenSSL: Отправить find output to openssl
- 4. UNIX Shell Scripting Output
- 5. linux shell scripting: hex string to bytes
- 6. Linux shell to windows batch file
- 7. shell script output in html + email that html
- 8. Set Modx Revolution: nl2br to Output HTML
- 9. clean angularjs output to plain html
- 10. phpmailer debug output to html variable
- 11. XMLWorkerHelper output to PDFCell
- 12. rCharts output to string
- 13. output System.Diagnostics.Debug to Console
- 14. Linux busybox shell script html форматирование
- 15. using shell command command output
- 16. Shell Redirect 'git clean' output
- 17. shell script return null output
- 18. Cron output to nothing
- 19. Linux bash read output описание
- 20. Json Output to AngularJs
- 21. shell/batch scripting to direct commands to adb shell
- 22. Return Perl-output to PHP
- 23. Приложение для Linux Linux Shell
- 24. Linux shell try catch наконец
- 25. Linux wget file output
- 26. linux shell script математическая операция
- 27. winforms output to commandline
- 28. org.hibernate.SQLQuery output to object
- 29. T4 Output to String
- 30. SQL to XML Output
Как выглядят результаты преобразования? Здесь нет узнаваемой структуры, которая может быть преобразована в теги HTML. Что именно вы пытаетесь достичь? –
Ваши данные, похоже, полны управляющих последовательностей ANSI. Это намеренно? – 2010-01-09 12:09:48
Связанный: http://stackoverflow.com/questions/245121/a-library-to-convert-ansi-escapes-terminal-formatting-color-codes-to-html – Tobu