multi-line.pl
资源名称:gateway-1.2.1 [点击查看]
上传用户:gzpyjq
上传日期:2013-01-31
资源大小:1852k
文件大小:1k
源码类别:
手机WAP编程
开发平台:
WINDOWS
- #!/usr/bin/perl -w
- # This script joins multi-line entries from access.log
- # cat bearerbox_access.log | multi-line.pl
- $|=1;
- $linenum=0;
- $result="";
- while($line = <STDIN>) {
- $linenum++;
- chop($line);
- next if $line =~ /Log begins/;
- next if $line =~ /Log ends/;
- if ( $result ne "" && $line =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} .+? .+? [SMSC:.*?] [SVC:.*?] [from:.*?] [to:.*?] [flags:.:.:.:.:.+?] [msg:.+?:.*$/) {
- $result = "";
- print STDERR "$linenum:$linen";
- }
- $result .= $line;
- if($result =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} .+? .+? [SMSC:.*?] [SVC:.*?] [from:.*?] [to:.*?] [flags:.:.:.:.:.+?] [msg:.+?:.*?] [udh:.+?:.*?]$/i) {
- print $result."n";
- $result="";
- }
- }