meillo@4: #!/bin/bash meillo@4: # meillo@4: # Autor: markus schnalke (prog.marmaro.de) meillo@4: # Autor: Julian Forster (www.ProgMaschine.de.vu) meillo@4: # meillo@4: meillo@4: meillo@4: if [ $# -eq 1 ]; then meillo@4: if [ $1 = '--version' ] ; then meillo@4: echo 'Buddylistgrapher (sed)' meillo@4: echo '======================' meillo@4: echo 'version 0.1' meillo@4: echo meillo@4: echo 'by Julian Forster (http://progmaschine.de.vu)' meillo@4: echo 'and Markus Schnalke (http://prog.marmaro.de)' meillo@4: exit 0 meillo@4: elif [ $1 = '--help' ] ; then meillo@4: echo 'Buddylistgrapher (sed)' meillo@4: echo '======================' meillo@4: echo meillo@4: echo "usage: $0 " meillo@4: echo meillo@4: echo "The grapher generates output to stdout." meillo@4: echo "This output is the input for the graphviz tools." meillo@4: echo meillo@4: echo "You can use it like this:" meillo@4: echo "$0 input.txt | dot -Tpng > pic.png" meillo@4: echo meillo@4: echo "ToDo:" meillo@4: echo "The program was written for one specific kind of input data," meillo@4: echo "so there is still some work to do to use it for general input." meillo@4: exit 0 meillo@4: else meillo@4: meillo@4: file=/tmp/`basename $0`-$$ meillo@4: file2=/tmp/`basename $0`-$$-2 meillo@4: meillo@4: # # collect all profil names (we only want them as nodes) meillo@4: # cat $file | while read line ; do meillo@4: # echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 meillo@4: # done meillo@4: # echo >> $file2 meillo@4: meillo@4: meillo@4: # TODO: fetch only edges for people having a profile meillo@4: meillo@4: # output meillo@4: meillo@4: sed -n -e ' meillo@4: /^Profil/{ meillo@6: s/Profil von: \(.\+\)/"\1";/ meillo@6: w /tmp/aa meillo@6: s/;$// meillo@4: h meillo@4: #p meillo@4: } meillo@4: meillo@4: meillo@4: /^Nachricht/{ meillo@4: G meillo@4: s/ - [-0-9]\+// meillo@4: s/Nachricht schreiben \(.\+\)\n/"\1" / meillo@4: s/"\(.\+\)" "\(.\+\)"/ "\2" -> "\1";/ meillo@4: meillo@4: # write out meillo@6: #p meillo@6: w /tmp/bb meillo@4: } meillo@4: ' $1 meillo@4: meillo@6: echo "digraph G {" meillo@6: grep -f /tmp/aa /tmp/bb meillo@4: echo "}" meillo@4: meillo@4: # rm $file $file2 meillo@4: exit 0 meillo@4: meillo@4: fi meillo@4: else meillo@4: echo "usage: $0 " meillo@4: exit 1 meillo@4: fi