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 can create a powershell script that runs the command, reads the data from the command's STDOUT then outputs the output to both the log file and the terminal for you to watch. You can use the commands Write-Output and Write-Host. 

Microsoft's site: <http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/tee-object.mspx>

Another option would be use find a tee program that will read input and divert it to two different outputs. I believe I have seen these for windows but I don't think they are standard.

Wikipedia: <http://en.wikipedia.org/wiki/Tee_(command)>
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

```