2012-12-03 19 views
1

我試圖做是否可以在批處理腳本中同時顯示和重定向標準輸出?

call script.bat > script.log 

但它不會顯示導致控制檯。 所以目前我要做的

call script.bat 
call script.bat > script.log 

這是非常低效的。

有沒有辦法將輸出顯示到控制檯並將其輸出到日誌文件? 我知道的選項之一是

call script.bat > script.log 
type script.log 

但是,如果script.bat只有在很長的批處理過程的步驟之一,我想看到的輸出每一步,因爲它並未真正發揮作用被調用,而不是在所有調用結束時執行一次類型。

回答

2

如果您使用Windows Power-Shell(正如我假設的Windows標記)一樣,有一個名爲Tee-Object的cmdlet。

help Tee-Object 

NAME 
    Tee-Object 

SYNOPSIS 
    Saves command output in a file or variable and displays it in the console. 

在Unix存在PROGRAMM 三通,其提供相同的功能。

+0

。但是,謝謝你讓我知道Power-Shell – ttback

+0

在這種情況下,你可以使用第三方程序。在http://unxutils.sourceforge.net/下找到的工具中,你會發現unix * tee *的本地win32端口。 – sge

相關問題