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
|
|
10 echo 'Buddylistgrapher'
|
|
11 echo 'shellscript edition'
|
|
12 echo 'version 0.1'
|
|
13 exit 0
|
|
14 else
|
|
15
|
|
16 file=/tmp/`basename $0`-$$
|
|
17 file2=/tmp/`basename $0`-$$-2
|
|
18
|
|
19 # extract all needed lines
|
|
20 grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
|
|
21
|
|
22 # collect all profil names (we only want them as nodes)
|
|
23 cat $file | while read line ; do
|
|
24 echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
|
|
25 done
|
|
26 echo >> $file2
|
|
27
|
|
28 #cat $file2
|
|
29 #exit
|
|
30
|
|
31
|
|
32 # output
|
|
33 echo "digraph G {"
|
|
34
|
|
35 cat $file | while read line ; do
|
|
36 isProfil=`echo $line | grep "Profil von:"`
|
|
37 if [ -n "$isProfil" ] ; then
|
|
38 name=$(echo $line | awk '{ print $3 }')
|
|
39 else
|
|
40 buddy=$(echo $line | awk '{ print $3 }')
|
|
41 if [ -n "`grep -F " $buddy " $file2`" ] ; then
|
|
42 echo " \"$name\" -> \"$buddy\";"
|
|
43 fi
|
|
44 fi
|
|
45 done
|
|
46
|
|
47 echo "}"
|
|
48
|
|
49 #rm $file $file2
|
|
50 exit 0
|
|
51
|
|
52 fi
|
|
53 else
|
|
54 echo "usage: $0 <input.txt>"
|
|
55 exit 1
|
|
56 fi
|