DEV Community

Query Filter
Query Filter

Posted on

counter

mkfifo counter.fifo

(
  t=0
  b=0
  while read cmd; do
    case "$cmd" in
      inc_t) ((t++)) ;;
      inc_b) ((b++)) ;;
      get)   echo "$t $b" ;;
    esac
  done < counter.fifo
) &
COUNTER_PID=$!


while IFS= read -r tableName; do
{
  echo inc_t > counter.fifo

  echo ""
  echo "Dumping table $tableName"
  echo ""

  bcpOUTToDir "$tableName"
  if [ $? -ne 0 ]; then
    echo inc_b > counter.fifo
    echo "ERROR: BCP OUT command failed for table $tableName"
  fi
} &

proceedWhenLessThanMaxJobs
done < "$TABLE_NAME_FILE"

wait
echo get > counter.fifo
read t b < counter.fifo

echo "Total tables: $t"
echo "Failures: $b"

kill "$COUNTER_PID"
rm counter.fifo

Enter fullscreen mode Exit fullscreen mode

Top comments (0)