批处理文件ping输出到文本文件 [英] batch file ping output to text file
本文介绍了批处理文件ping输出到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@echo off
ping www.google.com > pinglog.txt
pause
我有此命令,但是我的问题是,当您添加>"或">>"时,命令提示符将不会显示背景情况. ping后是否可以复制所有内容?
I have this command but my problem is when you add ">" or ">>" the command prompt will not show what is going on on the background. Is there a way that everything will be copied after doing the ping?
我也知道以下代码:
@echo off
ping www.google.com > pinglog.txt
type pinglog.txt
pause
但仍然,屏幕保持空白,好像什么也没发生.希望有人能帮忙
but still, the screen stays blank as if nothing happens. I hope someone can help
推荐答案
将管道插入Tee命令.
Pipe to a Tee command.
ping www.google.com | cscript //nologo tee.vbs - t pinglog.txt
这来自filter.bat/vbs.
This is from filter.bat/vbs.
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
Tee
filter tee <Filename>
filter t <Filename>
将Stdin写入文件并输出StdOut
Writes Stdin to a file and StdOut
示例
filter tee "%userprofile%\Desktop\winini.txt" < "%windir%\win.ini"
这篇关于批处理文件ping输出到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文