New script converting tab separated output to html

This commit is contained in:
Solene Rapenne 2019-07-09 09:06:19 +02:00
parent e6d5e1bcf7
commit 5bd1f20ca1
1 changed files with 40 additions and 0 deletions

40
extras/output2html.sh Normal file
View File

@ -0,0 +1,40 @@
#!/bin/sh
awk -F'\t' \
-v alert=1 \
-v check=1 \
-v params=1 \
-v previousstate=1 \
-v currentstate=1 \
-v triggerstate=1 '
BEGIN {
print "<html>"
print "<body>"
print "<table><thead><tr>"
if(alert) { print "<th>Alert</th>" }
if(check) { print "<th>check</th>" }
if(params) { print "<th>params</th>" }
if(previousstate) { print "<th>previous-state</th>" }
if(currentstate) { print "<th>current-state</th>" }
if(triggerstate) { print "<th>trigger-state</th>" }
print "</tr></thead><tbody>"
}
{
print "<tr>"
if(alert) { print "<td>"$1"</td>" }
if(check) { print "<td>"$2"</td>" }
if(params) { print "<td>"$3"</td>" }
if(previousstate) { print "<td>"$4"</td>" }
if(currentstate) { print "<td>"$5"</td>" }
if(triggerstate) { print "<td>"$6"</td>" }
print "</tr>"
}
END {
print "</tbody></table>"
print "</body></html>"
}'