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