counter

Published: (January 12, 2026 at 10:17 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Counter Script

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

  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  counter.fifo
read t b < counter.fifo

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

kill "$COUNTER_PID"
rm counter.fifo
Back to Blog

Related posts

Read more »