From 04eb10fb42b52ec29a55386ad488bae211845b18 Mon Sep 17 00:00:00 2001 From: Florian Schlegel Date: Sun, 4 Sep 2016 14:28:08 +0200 Subject: [PATCH] =?UTF-8?q?Umgang=20mit=20Strings=20verbessert=20(Support?= =?UTF-8?q?=20f=C3=BCr=20Dateinamen=20mit=20Leerzeichen)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- px6_convert.sh | 28 ++++++++++++++-------------- px6_send.sh | 10 +++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/px6_convert.sh b/px6_convert.sh index 6296c65..e2bd406 100755 --- a/px6_convert.sh +++ b/px6_convert.sh @@ -1,27 +1,27 @@ #! /bin/bash -INPUT=$1 -OUTPUT=$2 -export OW=$3 -export OH=$4 -W=$5 +INPUT="$1" +OUTPUT="$2" +export OW="$3" +export OH="$4" +W="$5" if [ "$OW" == "" ]; then OW=0; fi if [ "$OH" == "" ]; then OH=0; fi OPTIONS="-resize $W -set depth 8 -set colorspace RGB" #initial conversion -convert-im6 $OPTIONS $INPUT txt:- | awk -v ow=$OW -v oh=$OH 'match($0, /^([0-9]*),([0-9]*):.*#([0-9A-Fa-f]{6,8}) +r/, arr ){ print "PX " arr[1]+ow " " arr[2]+oh " " arr[3] }' > $OUTPUT +convert-im6 $OPTIONS "$INPUT" txt:- | awk -v ow=i"$OW" -v oh="$OH" 'match($0, /^([0-9]*),([0-9]*):.*#([0-9A-Fa-f]{6,8}) +r/, arr ){ print "PX " arr[1]+ow " " arr[2]+oh " " arr[3] }' > "$OUTPUT" echo optimizing >&2 # edge detection -convert-im6 $OPTIONS $INPUT -negate -edge 4 -negate txt:- | awk -v ow=$OW -v oh=$OH 'match($0, /^([0-9]*),([0-9]*):.*#000000/, arr ){ print "PX " arr[1]+ow " " arr[2]+oh " " }' > /tmp/px6_optimize -grep -Ff /tmp/px6_optimize $OUTPUT > ${OUTPUT}.tmp -grep -Ff /tmp/px6_optimize $OUTPUT >> ${OUTPUT}.tmp -grep -Ff /tmp/px6_optimize $OUTPUT >> ${OUTPUT}.tmp -grep -Ff /tmp/px6_optimize $OUTPUT >> ${OUTPUT}.tmp -cat ${OUTPUT}.tmp >> $OUTPUT -cat $OUTPUT | grep -ve " [a-fA-F0-9]\{6\}00" | shuf > ${OUTPUT}.tmp -mv ${OUTPUT}.tmp $OUTPUT +convert-im6 $OPTIONS "$INPUT" -negate -edge 4 -negate txt:- | awk -v ow="$OW" -v oh="$OH" 'match($0, /^([0-9]*),([0-9]*):.*#000000/, arr ){ print "PX " arr[1]+ow " " arr[2]+oh " " }' > /tmp/px6_optimize +grep -Ff /tmp/px6_optimize "$OUTPUT" > "${OUTPUT}.tmp" +grep -Ff /tmp/px6_optimize "$OUTPUT" >> "${OUTPUT}.tmp" +grep -Ff /tmp/px6_optimize "$OUTPUT" >> "${OUTPUT}.tmp" +grep -Ff /tmp/px6_optimize "$OUTPUT" >> "${OUTPUT}.tmp" +cat "${OUTPUT}.tmp" >> "$OUTPUT" +cat "$OUTPUT" | grep -ve " [a-fA-F0-9]\{6\}00" | shuf > "${OUTPUT}.tmp" +mv "${OUTPUT}.tmp" "$OUTPUT" rm /tmp/px6_optimize diff --git a/px6_send.sh b/px6_send.sh index a9c8fc2..eee52cc 100755 --- a/px6_send.sh +++ b/px6_send.sh @@ -1,8 +1,8 @@ #! /bin/bash -IP=$1 -PORT=$2 -PROCS=$3 -FILE=$4 +IP="$1" +PORT="$2" +PROCS="$3" +FILE="$4" PROCMAXTIME=60 MAINPID=$$ @@ -22,7 +22,7 @@ for i in $(seq 0 $(($PROCS-1))); do THISPID2=$BASHPID ( sleep $PROCMAXTIME; kill -9 $THISPID2 >/dev/null 2>&1 ) & echo "starting $(($i+1)) / $PROCS" - ( while kill -0 $THISPID2; do cat $FILE; done ) | nc $IP $PORT >/dev/null 2>&1 + ( while kill -0 $THISPID2; do cat "$FILE"; done ) | nc "$IP" "$PORT" >/dev/null 2>&1 ) >/dev/null 2>&1 done ) &