で、私は多くのalreadeをawnseredているこのトピックについての質問が、私の場合で私を助け残念ながらどれもが知っている: 私はこのように見ているのserver.logファイルがあります:分割テキストファイルの行と列
を################################################## ServerLog 07.07.2017 1:00:02,02 Software Version 2.5 (modified 30.06.2017 15:53) ################################################## Number of clients: 4 KB-Server is online --------------------------------------------------------------------- --------------------------------------------------------------------- Client 1 current client: \\192.168.0.22\Dauerversuch01 Connecting the network share successfull? client connected successfully No files found --------------------------------------------------------------------- --------------------------------------------------------------------- Client 2 current client: \\192.168.0.23\Dauerversuch01 Connecting the network share successfull? client connected successfully 3 Files found in the directory Copy from Client to local HDD: "\\192.168.0.23\Dauerversuch01 --> D:\Transfer" All files passed the md5 check Files won't get analysed by GlyphWorks copy files from hdd to server: "D:\Transfer --> \\mucs0244\Pool\CoC-AS\MessdatenQuantum\Dauerversuch_01_DUMMY\2017\07" All files passed the md5 check files were transfered successfully from the client to the server --------------------------------------------------------------------- --------------------------------------------------------------------- Client 3 current client: \\192.168.0.24\Dauerversuch Connecting the network share successfull? client connected successfully 3 Files found in the directory Copy from Client to local HDD: "\\192.168.0.24\Dauerversuch --> D:\Transfer" All files passed the md5 check Files won't get analysed by GlyphWorks copy files from hdd to server: "D:\Transfer --> \\mucs0244\Pool\CoC-AS\MessdatenQuantum\Dauerversuchspruefstand_02_SL20-4\2017\07" All files passed the md5 check files were transfered successfully from the client to the server --------------------------------------------------------------------- --------------------------------------------------------------------- Client 4 current client: \\192.168.0.25\Dauerversuch01 Connecting the network share successfull? client connected successfully 3 Files found in the directory Copy from Client to local HDD: "\\192.168.0.25\Dauerversuch01 --> D:\Transfer" All files passed the md5 check Files won't get analysed by GlyphWorks copy files from hdd to server: "D:\Transfer --> \\mucs0244\Pool\CoC-AS\MessdatenQuantum\Dauerversuch_01_DUMMY2\2017\07" All files passed the md5 check files were transfered successfully from the client to the server --------------------------------------------------------------------- --------------------------------------------------------------------- Batch erfolgreich beendet
あなたはすでに予想通り、server.logをクライアントログに分割したいと思います。具体的には、入力パラメータとしてクライアント番号を指定してPowerShellスクリプトを実行できるようにするには、スクリプトを出力する必要があります。このように見てclient2.log:
--------------------------------------------------------------------- Client 2 current client: \\192.168.0.23\Dauerversuch01 Connecting the network share successfull? client connected successfully 3 Files found in the directory Copy from Client to local HDD: "\\192.168.0.23\Dauerversuch01 --> D:\Transfer" All files passed the md5 check Files won't get analysed by GlyphWorks copy files from hdd to server: "D:\Transfer --> \\mucs0244\Pool\CoC-AS\MessdatenQuantum\Dauerversuch_01_DUMMY\2017\07" All files passed the md5 check files were transfered successfully from the client to the server ---------------------------------------------------------------------
を私は何ができる最善のは、この小さなスクリプト
$file = (GC H:\server.log)
foreach ($line in $file) {
if ($line -match "^Client \w+") {
$newfile = "$($line.Split(' ')[1]).txt"
} else {
$line | Out-File -Append $newfile
}
}
である。しかし、これは動作しません「----」の行を探し正しく動作しません。 。
これらを作成するために使用するソフトウェアのログを変更する必要がありますか?フリーフォームのテキストファイルを解析するのは本当の苦痛です。 – Vesper
実際には不幸なことではありませんが、ソフトウェアを変更して "--------"という行を1つだけ含めるようにしても構いませんが、どちらの方法でもアイデアはありません。 –
"(?s) (?= Client \ s \ d)。*?(?= ---)」は、クライアントのフルブロックと一致する必要があります。そして、もし私が間違っていないとすれば、マッチは配列(?)$ matchにあり、それをループし、マッチの最初の行に基づいてログを書き出します。 _(おそらくいくつかのより良い方法は正規表現を書く)_ – Jonas