Redirection Question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Redirection Question

#1 Post by alleypuppy » 28 Sep 2011 22:09

Is it possible to redirect the output of a command to a file and still read the output of the command in the CMD window as it's executing? I know you can redirect output using

Code: Select all

[command] > [file] 
or
[command] >> [file]

but it always nullifies the output on the screen.

Thanks for any help!

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Redirection Question

#2 Post by Ed Dyreen » 29 Sep 2011 00:01

'
That would be great, I tried something similar in the past:

Code: Select all

> "file.TMP" echo.This Works
< "file.TMP" set /p $str=
echo.$str=%$str%_
But some assembly wizard, could easily write a COM to do this, not me though. I just have a wild imagination:

Code: Select all

echo.This Works |STREAM.COM "File.TMP"

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Redirection Question

#3 Post by alleypuppy » 29 Sep 2011 21:20

Ed Dyreen wrote:'
That would be great, I tried something similar in the past:

Code: Select all

> "file.TMP" echo.This Works
< "file.TMP" set /p $str=
echo.$str=%$str%_

Hmmm... that works, but what if the command prompts you to do something? It is only shown after the command completes.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Redirection Question

#4 Post by dbenham » 30 Sep 2011 09:03

You want the equivalent of the Unix tee utility. There is no native Windows equivalent (unless you use PowerShell).

There are many ports of Unix utilities available for Windows, some of them free. I think the GnuWin CoreUtils for Windows package has a tee that will work.

Dave Benham

Post Reply