File: extract-console-from-debug-log.sh

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (47 lines) | stat: -rwxr-xr-x 1,145 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

if test $# -ne 2; then
    cat <<EOF
Usage:

  $0 <debug.log> <host>

Grub through <debug.log> extracting the console messages for <host>.
Specifically the boot messages.  For instance:

  $0 testing/pluto/basic-pluto-01/OUTPUT/debug.log east

(this script extracts the text by grubbing for low-level debug-log
message)

EOF
    exit 1
fi

debug=$1 ; shift
host=$1 ; shift

{
    cat ${debug}
} | {
    # extract the text read from the host's console
    sed -n \
	-e 's/^DEBUG .* '"${host}"' .*: read <<b.\(.*\)[^>]>>>*$/\1/p' \
	-e 's/^DEBUG .* '"${host}"' .*: send <<b.\(.*\)[^>]>>>*$/\1/p'
} | {
    # turn the text into a single very long line (the true \r\n were
    # escaped).
    tr -d '\n'
} | {
    # convert the escaped \r and \n into line breaks
    sed -e 's/\\r\\r\\n/\n/g' -e 's/\\r\\n/\n/g' -e 's/\\n/\n/g'
} | {
    # strip out magic escape characters used to fancy print on the
    # console (can this just be disabled).  Apparently \u2026 is
    # horizontal ellipsis.
    sed -e 's/\\x1b\[0;1;3[0-9]m//g' \
	-e 's/\\x1b\[0;3[0-9]m//g' \
	-e 's/\\x1b\[0m//g' \
	-e 's/\\x1bM\\r\\x1b\[K//' \
	-e 's/\\u2026/.../'
}