2015-02-01 3 views
0
@echo off 

ping www.google.com > pinglog.txt 

pause 

이 명령을 사용하고 있지만 ">"또는 ">>"을 추가하면 명령 프롬프트에 백그라운드에서 진행중인 작업이 표시되지 않습니다. ping을 수행 한 후에 모든 것이 복사 될 수있는 방법이 있습니까?배치 파일 ping을 텍스트 파일로 출력

은 나뿐만 아니라이 코드의 알고 : 아무 일도없는 것처럼

@echo off 

ping www.google.com > pinglog.txt 
type pinglog.txt 

pause 

하지만 여전히 화면에 아무것도 나오지 않습니다. 누군가가 도울 수 있기를 바랍니다.

+0

나는 당신이 뭘하려는 건지 잘 모르겠지만, '@echo off' 행을 삭제/주석 처리하십시오. – Yellows

+0

티가 필요합니다. – npocmaka

+0

Windows 및 해당 용도 찾기 [here] (http://stackoverflow.com/questions/11239924/windows-batch-tee-command/21841567#21841567) – ByteHamster

답변

0

Tee 명령에 대한 파이프.

ping www.google.com | cscript //nologo tee.vbs - t pinglog.txt 

이것은 filter.bat/vbs의 것입니다. 티

filter tee <Filename> 
filter t <Filename> 

Set Arg = WScript.Arguments 
set WshShell = createObject("Wscript.Shell") 
Set Inp = WScript.Stdin 
Set Outp = Wscript.Stdout 
If LCase(Arg(0)) = "tee" or LCase(Arg(0)) = "t" then Tee 

Sub Tee 
    On Error Resume Next 
    Set Fso = CreateObject("Scripting.FileSystemObject") 
    Set File = Fso.CreateTextFile(Arg(1), True) 
    If err.number <> 0 then 
     Outp.WriteLine "Error: " & err.number & " " & err.description & " from " & err.source 
     err.clear 
     wscript.exit 
    End If 
    Do Until Inp.AtEndOfStream 
     Line=Inp.readline 
     outp.writeline Line 
     File.WriteLine Line 
    Loop 
End Sub 

파일로 STDIN을 기록하고 STDOUT

filter tee "%userprofile%\Desktop\winini.txt" < "%windir%\win.ini" 
+0

하나의 박쥐 파일에있을 수 없습니까? –

+0

'wmic /append:c:\ping.txt PATH Win32_PingStatus 여기서 "address = '127.0.0.1'"응답 세트 가져 오기, statuscode "는'wmic 경로 Win32_PingStatus get /?'도움말을 참조하십시오. – Serenity