buddylistgrapher
annotate graph2.sh @ 0:21d9547ef242
initial commit
C++ and sh editions work similar
author | meillo@marmaro.de |
---|---|
date | Mon, 28 May 2007 17:41:28 +0200 |
parents | |
children | 6c327ae23d2c |
rev | line source |
---|---|
meillo@0 | 1 #!/bin/bash |
meillo@0 | 2 # |
meillo@0 | 3 # Autor: Julian Forster (www.ProgMaschine.de.vu) |
meillo@0 | 4 # Autor: markus schnalke (prog.marmaro.de) |
meillo@0 | 5 # |
meillo@0 | 6 |
meillo@0 | 7 |
meillo@0 | 8 if [ $# -eq 1 ]; then |
meillo@0 | 9 if [ $1 = '--version' ] ; then |
meillo@0 | 10 echo 'Buddylistgrapher' |
meillo@0 | 11 echo 'shellscript edition' |
meillo@0 | 12 echo 'version 0.1' |
meillo@0 | 13 exit 0 |
meillo@0 | 14 else |
meillo@0 | 15 |
meillo@0 | 16 file=/tmp/`basename $0`-$$ |
meillo@0 | 17 file2=/tmp/`basename $0`-$$-2 |
meillo@0 | 18 |
meillo@0 | 19 # extract all needed lines |
meillo@0 | 20 grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file |
meillo@0 | 21 |
meillo@0 | 22 # collect all profil names (we only want them as nodes) |
meillo@0 | 23 cat $file | while read line ; do |
meillo@0 | 24 echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 |
meillo@0 | 25 done |
meillo@0 | 26 echo >> $file2 |
meillo@0 | 27 |
meillo@0 | 28 #cat $file2 |
meillo@0 | 29 #exit |
meillo@0 | 30 |
meillo@0 | 31 |
meillo@0 | 32 # output |
meillo@0 | 33 echo "digraph G {" |
meillo@0 | 34 |
meillo@0 | 35 cat $file | while read line ; do |
meillo@0 | 36 isProfil=`echo $line | grep "Profil von:"` |
meillo@0 | 37 if [ -n "$isProfil" ] ; then |
meillo@0 | 38 name=$(echo $line | awk '{ print $3 }') |
meillo@0 | 39 else |
meillo@0 | 40 buddy=$(echo $line | awk '{ print $3 }') |
meillo@0 | 41 if [ -n "`grep -F " $buddy " $file2`" ] ; then |
meillo@0 | 42 echo " \"$name\" -> \"$buddy\";" |
meillo@0 | 43 fi |
meillo@0 | 44 fi |
meillo@0 | 45 done |
meillo@0 | 46 |
meillo@0 | 47 echo "}" |
meillo@0 | 48 |
meillo@0 | 49 #rm $file $file2 |
meillo@0 | 50 exit 0 |
meillo@0 | 51 |
meillo@0 | 52 fi |
meillo@0 | 53 else |
meillo@0 | 54 echo "usage: $0 <input.txt>" |
meillo@0 | 55 exit 1 |
meillo@0 | 56 fi |