ip.txtrem line by line"/> ip.txtrem line by line">

Home >Operation and Maintenance >Nginx >How to write Nginx log processing script under windows

How to write Nginx log processing script under windows

王林
王林forward
2023-05-14 16:37:06799browse

Running instructions: 20120917.txt is the log that needs to be analyzed, and last.csv is the statistical result (open with execl to facilitate statistics and sorting).
1. [File]
2. [Picture] Running screenshot.jpg

How to write Nginx log processing script under windows

3. [Picture] Running result

How to write Nginx log processing script under windows

4. [Code] Save as bat and double-click to open it

Copy code The code is as follows:

@echo off
setlocal enabledelayedexpansion

rem Extract ip to ip.txt file
awk.exe "{a[$1] =1;}end{for(i in a){print i;}}" 20120917 .txt > ip.txt

rem Read the ip in the ip.txt file line by line, and call the ip address source query interface of youdao.com
del result.txt
del last. txt
del last.csv

for /f "delims=" %%k in (ip.txt) do (
set /a b =1
wget-1.10.2.exe "http://www.youdao.com/smartresult-xml/search.s?type=ip&q=%%k" --output-document=temp.xml >nul 2>nul
echo is processing %% k
for /f "delims=" %%i in (temp.xml) do (
set /a num =1
set str=%%i
set str1=">% %k,!str! if !num! equ 5 (echo !str1! | strrpc "" "" | strrpc "" "">> result. txt)
)
set num=0
)

rem Processing result.txt quotation marks
for /f "tokens=2 delims=>" %%z in (' type result.txt') do (
for /f "delims=> last.txt
)

rem Name last.txt last.csv
rename last.txt last.csv
pause

The above is the detailed content of How to write Nginx log processing script under windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete