本帖最后由 WHY 于 2019-9-12 16:22 编辑
- @if(0)==(0) echo off
- cd /d "D:\se"
- :LOOP
- for /f %%i in ('WMIC OS get LocalDateTime ^| findstr [0-9]') do set "dt=%%i"
- dir /b /a-d /od *.txt | cscript //nologo //e:jscript "%~f0" >> ".\se\wltj%dt:~0,6%.txt"
- goto :LOOP
- pause & exit /b
- @end
-
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var arr = ['100M', '请求', '无法', 'unreach', '一般', 'failure'];
- var ip = [], jh = [], re = /B.../ig;
-
- var objFile = fso.OpenTextFile('.\\se\\ipref.txt', 1);
- while(!objFile.AtEndOfStream){
- var s = objFile.ReadLine();
- var m = s.match(/^ping\S*/i);
- if( !m ) continue;
- while( a = re.exec(s) ){ var k = a[0].toUpperCase(); if(!ip[k])ip[k] = m; }
- }
- objFile.Close();
-
- var objFile = fso.OpenTextFile('.\\se\\jhref.txt', 1);
- while(!objFile.AtEndOfStream){
- var s = objFile.ReadLine();
- var m = s.match(/^jh\S*/i);
- if( !m ) continue;
- while( a = re.exec(s) ){ var k = a[0].toUpperCase(); if(!jh[k])jh[k] = m; }
- }
- objFile.Close();
-
- while( !WSH.StdIn.AtEndOfStream ){
- var f = fso.GetFile( WSH.StdIn.ReadLine() );
- if( !/^B....*\.txt$/i.test(f.Name) ) continue;
- var dt = new Date( f.DateLastModified );
- var s1 = dt.toLocaleString(); //第1列
- var s2 = f.Name.substr(0,4).toUpperCase(); //第2列
- var s3 = ip[s2] ? ip[s2] : '-'; //第3列
- var s4 = jh[s2] ? jh[s2] : '-'; //第4列
- var s5 = getFileData(f.Path); //第5-11列
- WSH.Echo(s1 + '\t' + s2 + '\t' + s3 + '\t' + s4 + '\t' + s5);
- if(fso.FileExists(f.Path)) f.Delete(); //删除文件
- }
-
- function getFileData(fPath){
- var map = [], s = '', total = 0;
- for(var i in arr) map[arr[i]] = 0;
- var reg = new RegExp(arr.join('|'), 'ig');
- var objFile = fso.OpenTextFile(fPath, 1);
- var str = objFile.ReadAll();
- objFile.Close();
- while( a = reg.exec(str) ) map[a[0]]++;
- for(var i=0; i<arr.length; i++){ s += map[arr[i]] + '\t'; if(i>0)total += map[arr[i]]; }
- return s + total;
- }
-
- WScript.Sleep(20 * 1000); //延时20s
复制代码
|