0
|
1 #!/bin/bash
|
|
2 #
|
|
3 # Autor: Julian Forster (www.ProgMaschine.de.vu)
|
|
4 # Autor: markus schnalke (prog.marmaro.de)
|
|
5 #
|
|
6
|
|
7
|
|
8 if [ $# -eq 1 ]; then
|
|
9 if [ $1 = '--version' ] ; then
|
2
|
10 echo 'Buddylistgrapher (shell)'
|
|
11 echo '========================'
|
|
12 echo 'version 0.2'
|
|
13 echo
|
|
14 echo 'by Julian Forster (http://progmaschine.de.vu)'
|
|
15 echo 'and Markus Schnalke (http://prog.marmaro.de)'
|
|
16 exit 0
|
|
17 elif [ $1 = '--help' ] ; then
|
|
18 echo 'Buddylistgrapher (shell)'
|
|
19 echo '========================'
|
|
20 echo
|
|
21 echo "usage: $0 <input.txt>"
|
|
22 echo
|
|
23 echo "The grapher generates output to stdout."
|
|
24 echo "This output is the input for the graphviz tools."
|
|
25 echo
|
|
26 echo "You can use it like this:"
|
|
27 echo "$0 input.txt | dot -Tpng > pic.png"
|
|
28 echo
|
|
29 echo "ToDo:"
|
|
30 echo "The program was written for one specific kind of input data,"
|
|
31 echo "so there is still some work to do to use it for general input."
|
0
|
32 exit 0
|
|
33 else
|
|
34
|
|
35 file=/tmp/`basename $0`-$$
|
|
36 file2=/tmp/`basename $0`-$$-2
|
|
37
|
|
38 # extract all needed lines
|
|
39 grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
|
|
40
|
2
|
41
|
0
|
42 # collect all profil names (we only want them as nodes)
|
|
43 cat $file | while read line ; do
|
|
44 echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
|
|
45 done
|
|
46 echo >> $file2
|
|
47
|
|
48
|
|
49 # output
|
|
50 echo "digraph G {"
|
|
51
|
|
52 cat $file | while read line ; do
|
2
|
53 if [ -n "`echo $line | grep "Profil von:"`" ] ; then
|
0
|
54 name=$(echo $line | awk '{ print $3 }')
|
|
55 else
|
|
56 buddy=$(echo $line | awk '{ print $3 }')
|
|
57 if [ -n "`grep -F " $buddy " $file2`" ] ; then
|
|
58 echo " \"$name\" -> \"$buddy\";"
|
|
59 fi
|
|
60 fi
|
|
61 done
|
|
62
|
|
63 echo "}"
|
|
64
|
2
|
65 rm $file $file2
|
0
|
66 exit 0
|
|
67
|
|
68 fi
|
|
69 else
|
|
70 echo "usage: $0 <input.txt>"
|
|
71 exit 1
|
|
72 fi
|