Question: I've got a PHP script which I'm running from a command line (windows) that performs a variety of tasks, and the only output it gives is via 'print' statements which output direct to screen.

What I want to do is capture this to a log file as well.

I know I can do: 

```
php-cli script.php > log.txt  

```

But the problem with this approach is that all the output is written to the log file, but I can't see how things are running in the mean time (so I can stop the process if anything dodgy is happening).

Just to pre-empt other possible questions, I can't change all the print's to a log statement as there are far too many of them and I'd rather not change anything in the code lest I be blamed for something going fubar. Plus there's the lack of time aspect as well. I also have to run this on a windows machine.

Thanks in advance :)

Edit: Thanks for the answers guys, in the end I went with the browser method because that was the easiest and quickest to set up, although I am convinced there is an actual answer to this problem somewhere.

Answer: 
You want the "tee" command for Windows. See <http://en.wikipedia.org/wiki/Tee_(command)> 

Powershell includes a tee command, and there are also numerous versions of tee for Windows available, for instance: 

* <http://unxutils.sourceforge.net/>
* <http://www.chipstips.com/?p=129>

Also can be [implemented in VBScript](http://www.fpschultze.de/uploads/tee.vbs.txt) if you prefer.

**EDIT**: Just occurred to me I should also mention the tail command: <http://en.wikipedia.org/wiki/Tail_(Unix)>. Tail allows you to read the last *N* lines of a file, and also includes a "file monitor" mode that just continually displays the end of the file in real-time. This is perfect for log file monitoring since it allows you to watch the log in real-time without interfering with the process that's writing to the log. There are several implementations of tail for Windows, both command line and GUI based. Microsoft's Services For UNIX packages (or whatever they're calling it now) also include a version of tail. Some examples: 

* [mTail](http://ophilipp.free.fr/op_tail.htm)
* [Tail for Win32](http://tailforwin32.sourceforge.net/)
* [WinTail](http://www.baremetalsoft.com/wintail/)
* [MakeLogic Tail](http://www.makelogic.com/tail/TailHome.htm)

Some of these go far beyond just displaying the file in real-time as it updates and can send email alerts and colorize string matches, monitor multiple files at once, etc.
Slow:

```
for /f "delims=" %a in ('php-cli script.php') do @echo %a&echo %a>>log.txt

```

or in a batch file:

```
for /f "delims=" %%a in ('php-cli script.php') do @echo %%a&echo %%a>>log.txt

```