-
-
Save ushkinaz/7869356 to your computer and use it in GitHub Desktop.
Форматирует и выводит в консоль файл пакетов Агент.ру Требует наличия в системе: * xsltproc
* pygmentize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Форматирует и выводит в консоль файл пакетов Агент.ру | |
# Требует наличия в системе: | |
# xsltproc | |
# pygmentize | |
XSL_TRANSFORM='<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml" indent="yes"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:template match="/"> | |
<xsl:copy-of select="."/> | |
</xsl:template> | |
</xsl:stylesheet>' | |
xsl_file=$(mktemp /tmp/pack.tmp.XXXXXXXXXX.xsl) | |
xml_file=$(mktemp /tmp/pack.tmp.XXXXXXXXXX.xml) | |
echo $XSL_TRANSFORM > $xsl_file | |
# Самый сок | |
sed -e '/\(Outbound\|Inbound\) Message/,/Headers: /d;$d;s/Payload: //' $1 | xsltproc $xsl_file - > $xml_file | |
# Через пайпу не работает с некоторыми символами. wtf | |
pygmentize -l xml -f console $xml_file | |
rm -f "$xsl_file" | |
rm -f "$xml_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment