#!/bin/bash # Run automaton on textfile input and count results that match ^yes # $1 --> macro file (.pl) # $2 --> name of automaton # $3 --> input file if [ "$1" ] && [ "$2" ] && [ "$3" ] then if [ -e "$1" ] then if [ -e "$3" ] then name=$(basename $1 .pl) echo "" echo "..Run automaton $2 with input $3" fsa -aux $1 -raa $2 < $3 2> result 1> /dev/null # grep every line starting with yes or no # paste the results with testfile echo "..Create result file $name.result" egrep '^yes|^no' result | paste - $3 > $name.result # show result (last line of the fsa output -> result) tail -n 1 result # trash temporarly result file #rm result echo "" else echo "..input file $3 not found" fi else echo "..transducer file $1 not found" fi else echo "..Usage: testfsa [filename.pl] [automaton] [inputfile]" fi