On Ubuntu 11.10 GNU/Linux
pdflatex --enable-pipes --shell-escape mytexfile
with
%...
[This section currently is
\input{|"wc kmb-box.tex| tr -s ' ' | cut -d' ' -f 4"}
% 2000 characters are allowed here
\input{kmb-box}
%...
works nicely. ie, this uses wordcount (wc) to report how many characters are in the file kmb-box.tex, which is part of (included in) the document.
(btw If you wanted words rather than characters, just change the number in "-f 4")