[DOS] 將查詢或執行結果儲存文字檔

摘要:[DOS] 將查詢或執行結果儲存文字檔

在DOS如何將查詢或執行結果儲存文字檔呢?
接下來以ping來說明...

ex. 1  log檔存在當前目錄下
ping 127.0.0.1 > log.txt

Type log.txt
打開log.txt內容如下

Pinging 127.0.0.1 with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

以上為指令執行成功畫面,若是失敗則為錯誤或提示訊息。
ping 127.0.0.256 > log.txt
type log.txt
以下為錯誤指令錯誤訊息
Ping request could not find host 127.0.0.256. Please check the name and try agai
n.

ex. 2  log檔儲存在指定目錄
ipcongif  > D:\DosResult\log.txt
type D:\DosResult\log.txt

Windows IP Configuration


Ethernet adapter 區域連線 3:

   Connection-specific DNS Suffix  . :
   IP Address. . . . . . . . . . . . : 172.88.66.22
   Subnet Mask . . . . . . . . . . . : 255.255.254.0
   Default Gateway . . . . . . . . . : 172.88.66.254

ex. 3 過濾結果
只紀錄Request timed out的訊息
ping -t 192.168.1.1 |find "Request timed out" > log.txt
^C (Ctrl+C 強制中斷程序)
type log.txt
Request timed out.
Request timed out.