我目前正在处理批处理脚本以从日志文件中找到搜索字符串,并将重定向输出重定向到文本文件,并使用VB脚本将该文本文件邮寄给我们的团队。
我的实际查询是如何打印输出和日志文件一样。
在日志文件中,真实就像是
Summary Report:-
Source statistics:
Unprocessed: 0
Quarantined: 0
With Failures: 0
Imported: 2
Total Sources: 2
Message statistics:
Unprocessed: 0
Failed: 0
Success: 4865
Excluded: 0
Ignored: 0
Total Messages: 4865
我的输出就像:
=========================================================================
Summary Report:-
Source statistics:
Message statistics:
Unprocessed: 0
Unprocessed: 0
Quarantined: 0
With Failures: 0
Imported: 2
Total Sources: 2
Failed: 0
Success: 4865
Excluded: 0
Ignored: 0
Total Messages: 4666
Total Messages: 199
Total Sources: 2
Total Messages: 4865.
这是我的代码
@echo off
echo. > C:\Users\Pictures\scripts\test.log
set dirpath="My path is here"
for /f "delims=" %%x in ('dir /od /a-d /b "%dirpath%"') do set recent=%%x
findstr /i "\<^Summary Report:-\> \<statistics:\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<^Source statistics:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Unprocessed:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<\Quarantined:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /i "\<Failures:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Imported:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /i "\<Sources:\>" "Mypath\%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<^Message statistics:$\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Failed:\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Success:\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Excluded:\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Ignored:\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<Total Messages:$\>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
findstr /B "\<^No items to report>" "Mypath%recent%" >> C:\Users\Pictures\scripts\test.log
call C:\Users\\Pictures\AutoEmailSend.vbs
Exit 0
请帮助我将输出与日志文件顺序相同。我们必须在这里使用什么技术来获得用户定义的输出。提前谢谢。
答案 0 :(得分:1)
使用多个findstr
将所有字符串放在一个/c
中,这是一个示例:
findstr /i /c:"A" /c:"B" /c:"C" /c:"D" inputfile >>log
匹配字符串开始使用regexp:
findstr /i /r /c:"^A" /c:"^B" /c:"^C" /c:"^D" inputfile >>log
如果您的源字符串包含^$.*[]\><
之类的特殊字符,请在每个字符前加\
。
答案 1 :(得分:0)
只有您知道日志文件中的内容 - 但请对此进行测试,看看它是否能为您提供所需内容。
术语的顺序并不重要 - 它们将以与输入文件相同的顺序出现。
$('.check-fields').on('click', function () {
var reqlength = $('.required-entry').length;
console.log(reqlength);
var value = $('.required-entry').filter(function () {
return this.value != '';
});
if (value.length>=0 && (value.length !== reqlength)) {
alert('Please fill out all required fields.');
} else {
alert('Everything has a value.');
}
});