Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? TEE - duplicate output to STDERR

Aug
717
10
In Linux, I can easily achieve copying STDOUT to STDERR by
Code:
ps -al | tee /dev/stderr | wc -l
(I.e. list all processes and display a number of lines at the bottom.)
Is this possible in TCMD?
 
Now exactly the way you suggested, but you can get both output and the line count.

Code:
tasklist | tee con: | wc -l

Code:
(snip)
 8908  svchost
 7328  TextInputHost     Microsoft Text Input Application
 2660  tcc
 4784  wc

   Total of 108 processes
110 <--- from wc

Note that (as in your example), wc is also counting headers and footers.
 
Thanks, that works.

For anybody interested: CON: is an actual terminal device, not the I/O stream of an application. Thus redirecting output to it overrides any external redirections.

Thу full code now is install-cygwin.btm - Pastebin.com
Yup. I suspect that CON: is a handle which results (in C and the Win32 API) from something like this.

Code:
HANDLE h = CreateFile(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
 

Similar threads

Back
Top