Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a standalone tool that works just like TCC's TEE command?

189 views
Skip to first unread message

JJ

unread,
Sep 9, 2017, 5:22:49 PM9/9/17
to
TCC's TEE command copies standard input to both the standard output and to a
file.

e.g. for use with FOR command when parsing a command/program output without
manually ECHOing the lines.

Auric__

unread,
Sep 9, 2017, 6:43:02 PM9/9/17
to
Tee is a standard util in the *nix world... not so much in Windows. There are
various *nix-alike systems that run under Windows which include a version of
tee, or you can write your own, if you can program. It's pretty straight-
forward:

1. Open stdin, stdout, and the file to write to (listed on the command line).
2. Read from stdin to a variable, write said variable to stdout & the file.
3. When eof(stdin), close everything and exit.

--
Trying to anticipate every possible future contingency can drive you crazy,
and you'll generally guess wrong anyway.

JJ

unread,
Sep 9, 2017, 7:31:19 PM9/9/17
to
On Sat, 9 Sep 2017 22:42:59 -0000 (UTC), Auric__ wrote:
> JJ wrote:
>
>> TCC's TEE command copies standard input to both the standard output and to
>> a file.
>>
>> e.g. for use with FOR command when parsing a command/program output without
>> manually ECHOing the lines.
>
> Tee is a standard util in the *nix world... not so much in Windows. There are
> various *nix-alike systems that run under Windows which include a version of
> tee, or you can write your own, if you can program. It's pretty straight-
> forward:
>
> 1. Open stdin, stdout, and the file to write to (listed on the command line).
> 2. Read from stdin to a variable, write said variable to stdout & the file.
> 3. When eof(stdin), close everything and exit.

Dang, it was right under my nose! Why the heack didn't I thought of that
before? I already have a set of GNU utilities from IIRC, gnuwin32 project.
And yes, it has the tee program.

Thanks for that. :)

Auric__

unread,
Sep 10, 2017, 4:32:27 AM9/10/17
to
JJ wrote:

[snip]
> Dang, it was right under my nose! Why the heack didn't I thought of that
> before? I already have a set of GNU utilities from IIRC, gnuwin32
> project. And yes, it has the tee program.
>
> Thanks for that. :)

No problem.

You might want to get something newer than GnuWin32 (not specifically for
tee, but for everything else); the newest package is almost 7 years old.
MinGW (which I use) is still being updated -- there are files that were
uploaded just 6 weeks ago (w32api & mingwrt) -- while Cygwin is (apparently)
continuously updated, with an update 2 days ago.

--
I can't do that! It'll wake up THE HORROR!!!!

JJ

unread,
Sep 10, 2017, 9:33:07 AM9/10/17
to
On Sun, 10 Sep 2017 08:32:25 -0000 (UTC), Auric__ wrote:
>
> You might want to get something newer than GnuWin32 (not specifically for
> tee, but for everything else); the newest package is almost 7 years old.
> MinGW (which I use) is still being updated -- there are files that were
> uploaded just 6 weeks ago (w32api & mingwrt) -- while Cygwin is (apparently)
> continuously updated, with an update 2 days ago.

I actually already have GNU utilities from other packages such as MinGW,
MSYS, Cygwin, and Windows Services for UNIX.

The reason I still keep GnuWin32 is because each of the EXE file is
standalone and doesn't require additional DLL. I use it first, as long as it
works for my need. If not, I'd use the next most efficient binaries from
other packages.

Mark Blain

unread,
Sep 10, 2017, 7:37:54 PM9/10/17
to
JJ <jj4p...@vfemail.net> wrote in
news:l10k8xnon4hi.p3ty38verchk$.d...@40tude.net:

> The reason I still keep GnuWin32 is because each of the EXE file
> is standalone and doesn't require additional DLL. I use it first,
> as long as it works for my need. If not, I'd use the next most
> efficient binaries from other packages.

Busybox provides simplified versions of over 100 common *nix utilities
in one binary. It's a handy way to get your *nix fix portably. If you
try it, be sure to read the sections on wildcard expansion and the "--
install" option. https://frippery.org/busybox/



npocmaka

unread,
Sep 11, 2017, 10:49:39 AM9/11/17
to
Here you can get a script that emulates TEE command without need of external binaries : https://stackoverflow.com/questions/10711839/using-a-custom-tee-command-for-bat-file/10719322#10719322

JJ

unread,
Sep 11, 2017, 10:07:48 PM9/11/17
to
On Mon, 11 Sep 2017 07:49:37 -0700 (PDT), npocmaka wrote:
>
> Here you can get a script that emulates TEE command without need of
> external binaries : https://stackoverflow.com/questions/10711839/using-a-custom-tee-command-for-bat-file/10719322#10719322

VBScript and JScript do require external binary to run. It's called Windows
Scripting Host. i.e. WSCRIPT.EXE and CSCRIPT.EXE.

But nice idea, though. Cause this would make sure that the functionality is
be available on every installation of Windows - at least version 5, without
any third party tools.

JJ

unread,
Sep 11, 2017, 10:07:48 PM9/11/17
to
On 10 Sep 2017 23:37:52 GMT, Mark Blain wrote:
>
> Busybox provides simplified versions of over 100 common *nix utilities
> in one binary. It's a handy way to get your *nix fix portably. If you
> try it, be sure to read the sections on wildcard expansion and the "--
> install" option. https://frippery.org/busybox/

Thanks. I'll use it when I need various tools for one job.

Herbert Kleebauer

unread,
Sep 12, 2017, 11:03:13 AM9/12/17
to
You can also include a tee binary into the batch:

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off
certutil -f -decode %~f0 tee.exe>nul

dir |tee 2>log.txt

del tee.exe
goto :eof

-----BEGIN CERTIFICATE-----
TVpgAQEAAAAEAAAA//8AAGABAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAoAAAAA4fug4AtAnNIbgBTM0hTmljZSB0byBtZWV0IHNvbWVi
b2R5IHdobyBpcyBzdGlsbCB1c2luZyBET1MsDQpidXQgdGhpcyBwcm9ncmFtIHJl
cXVpcmVzIFdpbjMyLg0KJFBFAABMAQEAUHmlNgAAAAAAAAAA4AAPAQsBBQwAAgAA
AAAAAAAAAACUEAAAABAAAAAgAAAAAEAAABAAAAACAAAEAAAAAAAAAAQAAAAAAAAA
ACAAAAACAAAAAAAAAwAAAAAAEAAAEAAAAAAQAAAQAAAAAAAAEAAAAAAAAAAAAAAA
FBAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAUAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALnRleHQAAABkAQAAABAAAAACAAAAAgAA
AAAAAAAAAAAAAAAAIAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABeEAAAbBAAAHwQAACIEAAA
AAAAAEoQAAAAAAAAAAAAADwQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABLRVJO
RUwzMi5kbGwAAF4QAABsEAAAfBAAAIgQAAAAAAAAAABFeGl0UHJvY2VzcwAAAEdl
dFN0ZEhhbmRsZQAAAABSZWFkRmlsZQAAAABXcml0ZUZpbGUA6HsAAACD+P90B+gJ
AAAA6+9Q/xUAEEAAYDHAAwUMEUAAdRpq9P8VBBBAAKMQEUAAavX/FQQQQACjDBFA
AOgNAAAAoRARQADoAwAAAGGQw2oAjVQkFFJqAYPCEFJQ/xUMEEAACcB1CGoA/xUA
EEAAg3wkEAF18cMAAAAAAAAAAAAxwGADBWARQAB1DWr2/xUEEEAAo2ARQABqAI1U
JBBSagGDwhBSUP8VCBBAAAnAdQhqAP8VABBAAIN8JAwBdAjHRCQc/////2GQwwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAA==
-----END CERTIFICATE-----

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

The source:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tee.mac: copy stdin to stdout and stderr ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

winmain::
_10: bsr.l getc
cmpq.l #-1,r0
beq.b exit
bsr.l putc
br.b _10

exit: move.l r0,-(sp)
jsr.l (ExitProcess) ; exit program

putc: movem.l r0-r7,-(sp)
eor.l r0,r0
add.l _handle_stdout,r0
bne.b _10

moveq.l #-12,-(sp)
jsr.l (GetStdHandle)
move.l r0,_handle_stderr
moveq.l #-11,-(sp)
jsr.l (GetStdHandle)
move.l r0,_handle_stdout

_10: bsr.l _out
move.l _handle_stderr,r0
bsr.l _out
movem.l (sp)+,r0-r7
rts.l

_out: moveq.l #0,-(sp)
lea.l 5*4.b(r7),r1
move.l r1,-(sp)
moveq.l #1,-(sp)
addq.l #4*4,r1
move.l r1,-(sp)
move.l r0,-(sp)
jsr.l (WriteFile)
or.l r0,r0
bne.b _20
_30: moveq.l #0,-(sp)
jsr.l (ExitProcess)
_20: cmpq.l #1,4*4.b(r7){s7}
bne.b _30
rts.l

even4
_handle_stdout: dc.l 0
_handle_stderr: dc.l 0


getc: eor.l r0,r0
movem.l r0-r7,-(sp)
add.l _handle,r0
bne.b _10
moveq.l #-10,-(sp)
jsr.l (GetStdHandle)
move.l r0,_handle
_10: moveq.l #0,-(sp)
lea.l 4*4.b(r7),r1
move.l r1,-(sp)
moveq.l #1,-(sp)
addq.l #4*4,r1
move.l r1,-(sp)
move.l r0,-(sp)
jsr.l (ReadFile)
or.l r0,r0
bne.b _20
moveq.l #0,-(sp)
jsr.l (ExitProcess)
_20: cmpq.l #1,3*4.b(r7){s7}
beq.b _30
move.l #-1,7*4.b(r7){s7}
_30: movem.l (sp)+,r0-r7
rts.l

even4
_handle:dc.l 0



JJ

unread,
Sep 13, 2017, 9:31:36 AM9/13/17
to
On Tue, 12 Sep 2017 17:03:10 +0200, Herbert Kleebauer wrote:
> certutil -f -decode %~f0 tee.exe>nul

I don't embed binary file into a batch file for use with certutil because
certutil is not guaranteed to be available in all Windows (NT)
installations.
0 new messages