Logparser:循环过滤多个列表并使用列表值作为文件名输出到多个文件

时间:2012-10-08 11:00:49

标签: sql batch-file logparser

我陷入了这个陷阱困境的困境。所以除了这里之外别无他法。

批处理文件( disktrend.bat

@echo off    
pushd "Program Files (x86)\Log Parser 2.2\"
for /f "tokens=1,2 delims=," %%A in (d:logs\serverdrives.txt) do @logparser -i:tsv file:D:\logs\disktrend.sql?sd=%%A -o:chart -charttype:line > D:\logs\%%B.gif  

SQL文件( disktrend.sql

SELECT date,pfree using to_int(sub(to_real(100),to_real(replace_chr(free,'%','')))) as pfree,replace_chr(strcat(server,drive),':','') AS serverdrive from d:\logs\compiled\*.log where serverdrive =%sd%  

列表文件( serverdrives.txt

'SERV06F',SERV06F  
'SERV00F',SERV00F

日志文件示例内容(* .log

Date    Server  Drive   Free    Free Space  Total
20120914    SERV06      F:  79.55%  27619.02MB  34719.82MB
20120914    SERV00      F:  99.73%  34630.37MB  34723.81MB  

当我运行批处理脚本时,我得到以下错误:

错误

Invalid output filename ""   
Invalid output filename ""  

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

吃晚饭的时候突然出现了一个答案 我编辑了Batch和SQL文件 见下文。

批处理文件( disktrend.bat

@echo off    
pushd "Program Files (x86)\Log Parser 2.2\"
for /f "tokens=1,2 delims=," %%A in (d:logs\serverdrives.txt) do @logparser -i:tsv file:D:\logs\disktrend.sql?sd=%%A+filen=%%B -o:chart -charttype:smoothline -q:off -stats:off

SQL文件( disktrend.sql

SELECT to_string(date),pfree using to_int(sub(to_real(100),to_real(replace_chr(free,'%','')))) as pfree,replace_chr(strcat(server,drive),':','') AS serverdrive into d:\logs\%filen%.gif from d:\logs\compiled\*.log where serverdrive =%sd%