rfcommd

RFCOMM daemon to run filters on clients.
git clone git://arztpraxis-lohmann.de/rfcommd
Log | Files | Refs | LICENSE

euroklavfilter (683B)


      1 #!/bin/sh
      2 
      3 euroklavdb="/home/david/share/euroklav"
      4 dbpath="${euroklavdb}"
      5 
      6 if [ $# -gt 0 ];
      7 then
      8 	infile="$1"
      9 	case "${infile}" in
     10 	/dev/rfcomm*)
     11 		stty -F "${infile}" raw -echo -echoe -echok
     12 		;;
     13 	esac
     14 else
     15 	infile="/dev/stdin"
     16 fi
     17 
     18 cd "${dbpath}"
     19 datetime="$(date +%Y-%m-%d-%H-%M-%S)"
     20 outfile="euroklav-${datetime}.txt"
     21 cat "${infile}" \
     22 | while read -r line;
     23 do
     24 	case "${line}" in
     25 	$'\003'*)
     26 		datetime="$(date +%Y-%m-%d-%H-%M-%S)"
     27 		outfile="euroklav-${datetime}.txt"
     28 		;;
     29 	*" 4.07 4.08"*)
     30 		printf "%s\n" "${line}" >> ${outfile}
     31 		cat ${outfile} \
     32 			| tr -d '\002\003' \
     33 			| tr '\370' ' ' \
     34 			| tr '\346' ' ' \
     35 			| lpr
     36 		;;
     37 	esac
     38 	printf "%s\n" "${line}" >> ${outfile}
     39 done
     40