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