Parsing sendmail log file in a Java application

Are there any good parsing libraries for sendmail log files?
I already found these libraries but I'm not sure if they do what I need:
http://www.opennms.org/documentation/java-apidocs-stable/org/opennms/netmgt/syslogd/package-summary.html
http://code.google.com/p/jsyslogd/

>
I've written a simple text editor, and this editor saves files with a particular extension. It can both open and save files. I've put the text editor program in a JAR. What I'd like to do, if possible, is associate the file extension with the text editor program. That is, I'd like to, when I click on a file with the extension, have the text editor come up with the file opened in it.
Can anyone give me ideas on how to do this, please? >If the editor is launched using webstart, the launch file can suggest a file association.
Note that an application that accesses the local file system needs to be digitally signed before it can break out of the applet like 'sandbox' in which it runs, unless it uses the JNLP API to access the files. The JNLP API is available to any app. launched using webstart.
There is an example of both claiming a file extension, and accessing files using the JNLP API, in this [File Service Demo|http://pscode.org/jws/api.html#fs]. The complete source and a build file can be downloaded from the filetest.zip just near the launch buttons.
I suggest you try the sandboxed version first - if you think that will suit your user, go with that.
As an aside, for best chance of a solution, I recommend folks add [Duke stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview] to match the importance of the task.

Similar Messages

  • Parsing a log file on Weblogic

    Hi!
    I'd like to know how to get started on parsing a log file present in the default directory of Weblogic (ver 6.1 to be precise).
    I thought of using regular expressions, and use java.util.regex , but that is supported from JDK1.5 onwards, whereas WL6.1 supports JDK1.3.
    If u can also provide the code template for the same , that would be nice.
    Thanks in advance,
    Deepthy.

    uncle_alice wrote:
    String regex = "([^\"\\\\]++|\\\\.)++"{code} The trick is to match anything except a quotation mark or a backslash, OR match a backslash followed by anything (because the backslash is usually used to escape other characters as well, including backslashes).Superb! Thanks! I have to admit I've never used the ++ before (only the greedies), but that's the thing I was looking for.
    Just for the completeness, this is the whole thing that's able to parse a log line:
    {code}
    public class LogParser {
    private static final String NOSPACE_PARAM = "([^ ]++)";
    private static final String DATE_PARAM = "([^\\]]++)";
    private static final String ESCAPED_PARAM = "((?:[^\"\\\\]++|\\\\.)++)";
    private static final String PATTERN_STRING = NOSPACE_PARAM
    + " " + NOSPACE_PARAM
    + " " + NOSPACE_PARAM
    + " \\[" + DATE_PARAM + "\\]"
    + " \"" + ESCAPED_PARAM + "\""
    + " " + NOSPACE_PARAM
    + " " + NOSPACE_PARAM
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " " + NOSPACE_PARAM
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\""
    + " \"" + ESCAPED_PARAM + "\"";
    private static final Pattern PATTERN = Pattern.compile(PATTERN_STRING);
    public static String[] parse(String line) {
    Matcher m = PATTERN.matcher(line);
    if (m.matches()) {
    String[] result = new String[m.groupCount()];
    for (int i = 0; i < m.groupCount();) {
    result[i] = m.group(++i);
    return result;
    return null;
    {code}
    Any idea about the efficiency of this thing?

  • How to create a .exe file for a java application

    Hi, I want to create a .exe file for a java application I am developing so that I can schedule it to run at a particular time using Windows Scheduler on WinNT. Is there any way to accomplish this? Or is there any other way in which a Java application can be scheduled to run at a particular time on Windows everyday?

    Create a .bat file and run that. Just have, in the .bat file:
    java YourClassName Alternatively, you can use javaw YourClassName (without *.bat, just put it into Windows Scheduler like suggested above).
    using javaw won't pop up any window...

  • Can we run the batch file using simple java application

    Hello sir,
    we want to run the batch file using simple java application. i tried with some example, we run the exe files but not batch file.
    Runtime r = Runtime.getRuntime();
    r.exec("D:\\jboss\\bin\\run.bat");
    My application is server will run when we run the java appliation.
    any suggestion? plz give me the solutions

    yes you can run html file
    WEB.SHOW_DOCUMENT is a built-in that is used in Forms to call URL from a Web Form. It works much like the similar way that a link on an HTML page works and it takes two arguments, one is URL and second one is TARGET, in your case use following.
    WEB.SHOW_DOCUMENT('http://channas.iil.informatics.lk:8890/forms/frmservlet?config=abc.html', '_blank');
    Hope this will work for you
    Abbas

  • How to see the log file on the Reports Application server?

    Hi,
    I am new to this Reports, please correct me if i am wrong or in the wrong forum, we have a java based front-end application which calls oracle reports to display requested reports. We are using oracle reports (9i/10g). I need work on a report, It is working fine if i provide parameters on the report itself, but if i run from the application it is not running properly. I want to see the parameters the application is sending to this report, is there any way that i can some log file or any other one on the report server?
    thanks,

    Thank you.
    When you fire the processes to the report server you
    can trace the report with the following parameter:
    RWCLIENT.EXE SERVER=my_server
    TRACEFILE=c:\my_trace.trc
    TRACEMODE=TRACE_REPLACE
    TRACEOPTS=TRACE_ALL

  • Parse XMLFormatter log files back into LogRecords

    My app uses a java.util.logging.FileHandler and XMLFormatter to generate XML log files, which is great. Now I want to display those logs in my app's web admin console.
    I assumed that there would be an easy way to read my XML logs files back into a List of LogRecord objects, but my initial investigation has revealed nothing.
    Anyone have any advice?

    If you remove an "active" log file, then this can cause problems. If you remove an archieved log file, then it is OK.
    If you change the log directory, then you SHOULD inform all your applications that use this directory... Depending on the service, this information is usually stored inside the config files of the services.
    Mihalis.

  • How to implement logging functonolity in my java application

    Hi.
    I want to add logging functionality in my java project.Iam using jdk1.5.I have written following log4j.properties.This property file i need to keep it in com.format.src.property folder .All java files are there in com.format.src folder.
    log4j.rootCategory=DEBUG, FILE, CONSOLE
    ### A bootstrap file appender
    log4j.appender.FILE=org.jboss.logging.appender.FileAppender
    log4j.appender.FILE.File=${jboss.server.log.dir}/${HOSTSHORTNAME}-${jboss.server.name}-boot.log
    log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
    log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
    log4j.appender.FILE.Append=false
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.Threshold=INFO
    log4j.appender.CONSOLE.Target=System.out
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
    Could you reply me the steps to implement logging in my project.
    Thanks in advance
    alex

    1) Put the Apache Commons Logging jar into your "lib" folder.
    2) Create your properties file as "log4j.properties"
    3) Keep it inside the folder where you have your "src" (ie. ur "src", "classes", & "log4j.properties" should be in the same folder)
    4) Import "org.apache.log4j.Logger;"
    5) Create an instance of "Logger" as follows;
    Logger log = Logger.getLogger(YourClassName.class.getName());
    6) Use the created "log" instance when applicable as follows:
    log.info("Whatever the message");
    log.debug("Whatever the message");
    log.error("Whatever the message");
    log.fatal("Whatever the message"); ...etc
    Hope u got it... Happy coding... :)
    Cheers,
    Asela.

  • Creating an xdp file from flex/java application

    Hi,
    I have an application in Flex 4  and As 3.When I click a button in flex application I have to generate a file in java with
    extension xdp.When I try this locally(Run as java application) the file is generating  correctly.When i compile the applic
    ation and try it, the file is not writing correctly.Do someone have any idea about creating an xdp file from flex application?
    i am using blazeds to connect java and flex4.When i opens the file in notepad the file is writing correctly.There is only problem in openig an xdp file...
    please help me.

    specifically:
    Runtime.getRuntime().exec("filename.exe")

  • How to exit batch file after launching java application

    hello, I have created a simple java application and a batch file to launch the application. but when execute the batch file the application execute but the batch file still
    appear. I want to launch the application and immediately close the batch file after the application appears.
    Best Regards,
    Boulebtina

    In the batch script use the "START" command to start the program. To use it you need to have the script browse to the application directory first as shown below:
    c:
    cd MyApplication\ApplicationFolder
    START myApp.exe
    exitThis will start an application that is stored in C:\MyApplication\ApplicationFolder\myApp.exe. I use this quite a bit and works well for me.

  • How to create a exe file from a Java application

    hi,
    i have developed an application in java,now i want to distribute it to my client, for this i need to build a .exe file out of this application.
    i already have a jar file ,now can i convert a jar file to a exe file.
    im trying this out with JSmooth project but im getting it right, so can anyone help me .
    thanks,
    vishal j

    if u use dos to run your app like
    "java myapp"
    u can create a shortcut link
    in target wright java remove the path
    just leave the file name without the extension,
    like this Target: "java myapp"
    when u click on appy u'll c that java gets its full path, thats fine
    that works 4 me, ofcourse ur client needs to have JRE or JDK.

  • Parse robocopy Log File - new value

    Hello,
    I have found a script, that parse the robocopy log file, which looks like this:
       ROBOCOPY     ::     Robust File Copy for Windows                             
      Started : Thu Aug 07 09:30:18 2014
       Source : e:\testfolder\
         Dest : w:\testfolder\
        Files : *.*
      Options : *.* /V /NDL /S /E /COPYALL /NP /IS /R:1 /W:5
         Same          14.6 g e:\testfolder\bigfile - Copy (5).out
         Same          14.6 g e:\testfolder\bigfile - Copy.out
         Same          14.6 g e:\testfolder\bigfile.out
                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         1         0         1         0        
    0         0
       Files :         3         3         0         0        
    0         0
       Bytes :  43.969 g  43.969 g         0         0         0         0
       Times :   0:05:44   0:05:43                       0:00:00   0:00:00
       Speed :           137258891 Bytes/sec.
       Speed :            7854.016 MegaBytes/min.
       Ended : Thu Aug 07 09:36:02 2014
    Most values at output file are included, but the two speed paramter not.
    How can I get this two speed paramters at output file?
    Here is the script:
    param(
    [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false,HelpMessage='Source Path with no trailing slash')][string]$SourcePath,
    [switch]$fp
    write-host "Robocopy log parser. $(if($fp){"Parsing file entries"} else {"Parsing summaries only, use -fp to parse file entries"})"
    #Arguments
    # -fp File parse. Counts status flags and oldest file Slower on big files.
    $ElapsedTime = [System.Diagnostics.Stopwatch]::StartNew()
    $refreshrate=1 # progress counter refreshes this often when parsing files (in seconds)
    # These summary fields always appear in this order in a robocopy log
    $HeaderParams = @{
    "04|Started" = "date";
    "01|Source" = "string";
    "02|Dest" = "string";
    "03|Options" = "string";
    "07|Dirs" = "counts";
    "08|Files" = "counts";
    "09|Bytes" = "counts";
    "10|Times" = "counts";
    "05|Ended" = "date";
    #"06|Duration" = "string"
    $ProcessCounts = @{
    "Processed" = 0;
    "Error" = 0;
    "Incomplete" = 0
    $tab=[char]9
    $files=get-childitem $SourcePath
    $writer=new-object System.IO.StreamWriter("$(get-location)\robocopy-$(get-date -format "dd-MM-yyyy_HH-mm-ss").csv")
    function Get-Tail([object]$reader, [int]$count = 10) {
    $lineCount = 0
    [long]$pos = $reader.BaseStream.Length - 1
    while($pos -gt 0)
    $reader.BaseStream.position=$pos
    # 0x0D (#13) = CR
    # 0x0A (#10) = LF
    if ($reader.BaseStream.ReadByte() -eq 10)
    $lineCount++
    if ($lineCount -ge $count) { break }
    $pos--
    # tests for file shorter than requested tail
    if ($lineCount -lt $count -or $pos -ge $reader.BaseStream.Length - 1) {
    $reader.BaseStream.Position=0
    } else {
    # $reader.BaseStream.Position = $pos+1
    $lines=@()
    while(!$reader.EndOfStream) {
    $lines += $reader.ReadLine()
    return $lines
    function Get-Top([object]$reader, [int]$count = 10)
    $lines=@()
    $lineCount = 0
    $reader.BaseStream.Position=0
    while(($linecount -lt $count) -and !$reader.EndOfStream) {
    $lineCount++
    $lines += $reader.ReadLine()
    return $lines
    function RemoveKey ( $name ) {
    if ( $name -match "|") {
    return $name.split("|")[1]
    } else {
    return ( $name )
    function GetValue ( $line, $variable ) {
    if ($line -like "*$variable*" -and $line -like "* : *" ) {
    $result = $line.substring( $line.IndexOf(":")+1 )
    return $result
    } else {
    return $null
    function UnBodgeDate ( $dt ) {
    # Fixes RoboCopy botched date-times in format Sat Feb 16 00:16:49 2013
    if ( $dt -match ".{3} .{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}" ) {
    $dt=$dt.split(" ")
    $dt=$dt[2],$dt[1],$dt[4],$dt[3]
    $dt -join " "
    if ( $dt -as [DateTime] ) {
    return $dt.ToStr("dd/MM/yyyy hh:mm:ss")
    } else {
    return $null
    function UnpackParams ($params ) {
    # Unpacks file count bloc in the format
    # Dirs : 1827 0 1827 0 0 0
    # Files : 9791 0 9791 0 0 0
    # Bytes : 165.24 m 0 165.24 m 0 0 0
    # Times : 1:11:23 0:00:00 0:00:00 1:11:23
    # Parameter name already removed
    if ( $params.length -ge 58 ) {
    $params = $params.ToCharArray()
    $result=(0..5)
    for ( $i = 0; $i -le 5; $i++ ) {
    $result[$i]=$($params[$($i*10 + 1) .. $($i*10 + 9)] -join "").trim()
    $result=$result -join ","
    } else {
    $result = ",,,,,"
    return $result
    $sourcecount = 0
    $targetcount = 1
    # Write the header line
    $writer.Write("File")
    foreach ( $HeaderParam in $HeaderParams.GetEnumerator() | Sort-Object Name ) {
    if ( $HeaderParam.value -eq "counts" ) {
    $tmp="~ Total,~ Copied,~ Skipped,~ Mismatch,~ Failed,~ Extras"
    $tmp=$tmp.replace("~","$(removekey $headerparam.name)")
    $writer.write(",$($tmp)")
    } else {
    $writer.write(",$(removekey $HeaderParam.name)")
    if($fp){
    $writer.write(",Scanned,Newest,Summary")
    $writer.WriteLine()
    $filecount=0
    # Enumerate the files
    foreach ($file in $files) {
    $filecount++
    write-host "$filecount/$($files.count) $($file.name) ($($file.length) bytes)"
    $results=@{}
    $Stream = $file.Open([System.IO.FileMode]::Open,
    [System.IO.FileAccess]::Read,
    [System.IO.FileShare]::ReadWrite)
    $reader = New-Object System.IO.StreamReader($Stream)
    #$filestream=new-object -typename System.IO.StreamReader -argumentlist $file, $true, [System.IO.FileAccess]::Read
    $HeaderFooter = Get-Top $reader 16
    if ( $HeaderFooter -match "ROBOCOPY :: Robust File Copy for Windows" ) {
    if ( $HeaderFooter -match "Files : " ) {
    $HeaderFooter = $HeaderFooter -notmatch "Files : "
    [long]$ReaderEndHeader=$reader.BaseStream.position
    $Footer = Get-Tail $reader 16
    $ErrorFooter = $Footer -match "ERROR \d \(0x000000\d\d\) Accessing Source Directory"
    if ($ErrorFooter) {
    $ProcessCounts["Error"]++
    write-host -foregroundcolor red "`t $ErrorFooter"
    } elseif ( $footer -match "---------------" ) {
    $ProcessCounts["Processed"]++
    $i=$Footer.count
    while ( !($Footer[$i] -like "*----------------------*") -or $i -lt 1 ) { $i-- }
    $Footer=$Footer[$i..$Footer.Count]
    $HeaderFooter+=$Footer
    } else {
    $ProcessCounts["Incomplete"]++
    write-host -foregroundcolor yellow "`t Log file $file is missing the footer and may be incomplete"
    foreach ( $HeaderParam in $headerparams.GetEnumerator() | Sort-Object Name ) {
    $name = "$(removekey $HeaderParam.Name)"
    $tmp = GetValue $($HeaderFooter -match "$name : ") $name
    if ( $tmp -ne "" -and $tmp -ne $null ) {
    switch ( $HeaderParam.value ) {
    "date" { $results[$name]=UnBodgeDate $tmp.trim() }
    "counts" { $results[$name]=UnpackParams $tmp }
    "string" { $results[$name] = """$($tmp.trim())""" }
    default { $results[$name] = $tmp.trim() }
    if ( $fp ) {
    write-host "Parsing $($reader.BaseStream.Length) bytes"
    # Now go through the file line by line
    $reader.BaseStream.Position=0
    $filesdone = $false
    $linenumber=0
    $FileResults=@{}
    $newest=[datetime]"1/1/1900"
    $linecount++
    $firsttick=$elapsedtime.elapsed.TotalSeconds
    $tick=$firsttick+$refreshrate
    $LastLineLength=1
    try {
    do {
    $line = $reader.ReadLine()
    $linenumber++
    if (($line -eq "-------------------------------------------------------------------------------" -and $linenumber -gt 16) ) {
    # line is end of job
    $filesdone=$true
    } elseif ($linenumber -gt 16 -and $line -gt "" ) {
    $buckets=$line.split($tab)
    # this test will pass if the line is a file, fail if a directory
    if ( $buckets.count -gt 3 ) {
    $status=$buckets[1].trim()
    $FileResults["$status"]++
    $SizeDateTime=$buckets[3].trim()
    if ($sizedatetime.length -gt 19 ) {
    $DateTime = $sizedatetime.substring($sizedatetime.length -19)
    if ( $DateTime -as [DateTime] ){
    $DateTimeValue=[datetime]$DateTime
    if ( $DateTimeValue -gt $newest ) { $newest = $DateTimeValue }
    if ( $elapsedtime.elapsed.TotalSeconds -gt $tick ) {
    $line=$line.Trim()
    if ( $line.Length -gt 48 ) {
    $line="[...]"+$line.substring($line.Length-48)
    $line="$([char]13)Parsing > $($linenumber) ($(($reader.BaseStream.Position/$reader.BaseStream.length).tostring("P1"))) - $line"
    write-host $line.PadRight($LastLineLength) -NoNewLine
    $LastLineLength = $line.length
    $tick=$tick+$refreshrate
    } until ($filesdone -or $reader.endofstream)
    finally {
    $reader.Close()
    $line=$($([string][char]13)).padright($lastlinelength)+$([char]13)
    write-host $line -NoNewLine
    $writer.Write("`"$file`"")
    foreach ( $HeaderParam in $HeaderParams.GetEnumerator() | Sort-Object Name ) {
    $name = "$(removekey $HeaderParam.Name)"
    if ( $results[$name] ) {
    $writer.Write(",$($results[$name])")
    } else {
    if ( $ErrorFooter ) {
    #placeholder
    } elseif ( $HeaderParam.Value -eq "counts" ) {
    $writer.Write(",,,,,,")
    } else {
    $writer.Write(",")
    if ( $ErrorFooter ) {
    $tmp = $($ErrorFooter -join "").substring(20)
    $tmp=$tmp.substring(0,$tmp.indexof(")")+1)+","+$tmp
    $writer.write(",,$tmp")
    } elseif ( $fp ) {
    $writer.write(",$LineCount,$($newest.ToString('dd/MM/yyyy hh:mm:ss'))")
    foreach ( $FileResult in $FileResults.GetEnumerator() ) {
    $writer.write(",$($FileResult.Name): $($FileResult.Value);")
    $writer.WriteLine()
    } else {
    write-host -foregroundcolor darkgray "$($file.name) is not recognised as a RoboCopy log file"
    write-host "$filecount files scanned in $($elapsedtime.elapsed.tostring()), $($ProcessCounts["Processed"]) complete, $($ProcessCounts["Error"]) have errors, $($ProcessCounts["Incomplete"]) incomplete"
    write-host "Results written to $($writer.basestream.name)"
    $writer.close()
    I hope somebody can help me,
    Horst
    Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; TFS 2013; IIS 7.5

    Hi Horst,
    To convert mutiple robocopy log files to a .csv file with "speed" option, the script below may be helpful for you, I tested with a single robocopy log file, and the .csv file will output to "D:\":
    $SourcePath="e:\1\1.txt" #robocopy log file
    write-host "Robocopy log parser. $(if($fp){"Parsing file entries"} else {"Parsing summaries only, use -fp to parse file entries"})"
    #Arguments
    # -fp File parse. Counts status flags and oldest file Slower on big files.
    $ElapsedTime = [System.Diagnostics.Stopwatch]::StartNew()
    $refreshrate=1 # progress counter refreshes this often when parsing files (in seconds)
    # These summary fields always appear in this order in a robocopy log
    $HeaderParams = @{
     "04|Started" = "date"; 
     "01|Source" = "string";
     "02|Dest" = "string";
     "03|Options" = "string";
     "09|Dirs" = "counts";
     "10|Files" = "counts";
     "11|Bytes" = "counts";
     "12|Times" = "counts";
     "05|Ended" = "date";
     "07|Speed" = "default";
     "08|Speednew" = "default"
    $ProcessCounts = @{
     "Processed" = 0;
     "Error" = 0;
     "Incomplete" = 0
    $tab=[char]9
    $files=get-childitem $SourcePath
    $writer=new-object System.IO.StreamWriter("D:\robocopy-$(get-date -format "dd-MM-yyyy_HH-mm-ss").csv")
    function Get-Tail([object]$reader, [int]$count = 10) {
     $lineCount = 0
     [long]$pos = $reader.BaseStream.Length - 1
     while($pos -gt 0)
      $reader.BaseStream.position=$pos
      # 0x0D (#13) = CR
      # 0x0A (#10) = LF
      if ($reader.BaseStream.ReadByte() -eq 10)
       $lineCount++
       if ($lineCount -ge $count) { break }
      $pos--
     # tests for file shorter than requested tail
     if ($lineCount -lt $count -or $pos -ge $reader.BaseStream.Length - 1) {
      $reader.BaseStream.Position=0
     } else {
      # $reader.BaseStream.Position = $pos+1
     $lines=@()
     while(!$reader.EndOfStream) {
      $lines += $reader.ReadLine()
     return $lines
    function Get-Top([object]$reader, [int]$count = 10)
     $lines=@()
     $lineCount = 0
     $reader.BaseStream.Position=0
     while(($linecount -lt $count) -and !$reader.EndOfStream) {
      $lineCount++
      $lines += $reader.ReadLine()  
     return $lines
    function RemoveKey ( $name ) {
     if ( $name -match "|") {
      return $name.split("|")[1]
     } else {
      return ( $name )
    function GetValue ( $line, $variable ) {
     if ($line -like "*$variable*" -and $line -like "* : *" ) {
      $result = $line.substring( $line.IndexOf(":")+1 )
      return $result
     } else {
      return $null
    }function UnBodgeDate ( $dt ) {
     # Fixes RoboCopy botched date-times in format Sat Feb 16 00:16:49 2013
     if ( $dt -match ".{3} .{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}" ) {
      $dt=$dt.split(" ")
      $dt=$dt[2],$dt[1],$dt[4],$dt[3]
      $dt -join " "
     if ( $dt -as [DateTime] ) {
      return $dt.ToStr("dd/MM/yyyy hh:mm:ss")
     } else {
      return $null
    function UnpackParams ($params ) {
     # Unpacks file count bloc in the format
     # Dirs :      1827         0      1827         0         0         0
     # Files :      9791         0      9791         0         0         0
     # Bytes :  165.24 m         0  165.24 m         0         0         0
     # Times :   1:11:23   0:00:00                       0:00:00   1:11:23
     # Parameter name already removed
     if ( $params.length -ge 58 ) {
      $params = $params.ToCharArray()
      $result=(0..5)
      for ( $i = 0; $i -le 5; $i++ ) {
       $result[$i]=$($params[$($i*10 + 1) .. $($i*10 + 9)] -join "").trim()
      $result=$result -join ","
     } else {
      $result = ",,,,,"
     return $result
    $sourcecount = 0
    $targetcount = 1
    # Write the header line
    $writer.Write("File")
    foreach ( $HeaderParam in $HeaderParams.GetEnumerator() | Sort-Object Name ) {
     if ( $HeaderParam.value -eq "counts" ) {
      $tmp="~ Total,~ Copied,~ Skipped,~ Mismatch,~ Failed,~ Extras"
      $tmp=$tmp.replace("~","$(removekey $headerparam.name)")
      $writer.write(",$($tmp)")
     } else {
      $writer.write(",$(removekey $HeaderParam.name)")
    if($fp){
     $writer.write(",Scanned,Newest,Summary")
    $writer.WriteLine()
    $filecount=0
    # Enumerate the files
    foreach ($file in $files) { 
     $filecount++
        write-host "$filecount/$($files.count) $($file.name) ($($file.length) bytes)"
     $results=@{}
    $Stream = $file.Open([System.IO.FileMode]::Open,
                       [System.IO.FileAccess]::Read,
                        [System.IO.FileShare]::ReadWrite)
     $reader = New-Object System.IO.StreamReader($Stream)
     #$filestream=new-object -typename System.IO.StreamReader -argumentlist $file, $true, [System.IO.FileAccess]::Read
     $HeaderFooter = Get-Top $reader 16
     if ( $HeaderFooter -match "ROBOCOPY     ::     Robust File Copy for Windows" ) {
      if ( $HeaderFooter -match "Files : " ) {
       $HeaderFooter = $HeaderFooter -notmatch "Files : "
      [long]$ReaderEndHeader=$reader.BaseStream.position
      $Footer = Get-Tail $reader 16
      $ErrorFooter = $Footer -match "ERROR \d \(0x000000\d\d\) Accessing Source Directory"
      if ($ErrorFooter) {
       $ProcessCounts["Error"]++
       write-host -foregroundcolor red "`t $ErrorFooter"
      } elseif ( $footer -match "---------------" ) {
       $ProcessCounts["Processed"]++
       $i=$Footer.count
       while ( !($Footer[$i] -like "*----------------------*") -or $i -lt 1 ) { $i-- }
       $Footer=$Footer[$i..$Footer.Count]
       $HeaderFooter+=$Footer
      } else {
       $ProcessCounts["Incomplete"]++
       write-host -foregroundcolor yellow "`t Log file $file is missing the footer and may be incomplete"
      foreach ( $HeaderParam in $headerparams.GetEnumerator() | Sort-Object Name ) {
       $name = "$(removekey $HeaderParam.Name)"
                            if ($name -eq "speed"){ #handle two speed
                            ($HeaderFooter -match "$name : ")|foreach{
                             $tmp=GetValue $_ "speed"
                             $results[$name] = $tmp.trim()
                             $name+="new"}
                            elseif ($name -eq "speednew"){} #handle two speed
                            else{
       $tmp = GetValue $($HeaderFooter -match "$name : ") $name
       if ( $tmp -ne "" -and $tmp -ne $null ) {
        switch ( $HeaderParam.value ) {
         "date" { $results[$name]=UnBodgeDate $tmp.trim() }
         "counts" { $results[$name]=UnpackParams $tmp }
         "string" { $results[$name] = """$($tmp.trim())""" }  
         default { $results[$name] = $tmp.trim() }  
      if ( $fp ) {
       write-host "Parsing $($reader.BaseStream.Length) bytes"
       # Now go through the file line by line
       $reader.BaseStream.Position=0
       $filesdone = $false
       $linenumber=0
       $FileResults=@{}
       $newest=[datetime]"1/1/1900"
       $linecount++
       $firsttick=$elapsedtime.elapsed.TotalSeconds
       $tick=$firsttick+$refreshrate
       $LastLineLength=1
       try {
        do {
         $line = $reader.ReadLine()
         $linenumber++
         if (($line -eq "-------------------------------------------------------------------------------" -and $linenumber -gt 16)  ) {
          # line is end of job
          $filesdone=$true
         } elseif ($linenumber -gt 16 -and $line -gt "" ) {
          $buckets=$line.split($tab)
          # this test will pass if the line is a file, fail if a directory
          if ( $buckets.count -gt 3 ) {
           $status=$buckets[1].trim()
           $FileResults["$status"]++
           $SizeDateTime=$buckets[3].trim()
           if ($sizedatetime.length -gt 19 ) {
            $DateTime = $sizedatetime.substring($sizedatetime.length -19)
            if ( $DateTime -as [DateTime] ){
             $DateTimeValue=[datetime]$DateTime
             if ( $DateTimeValue -gt $newest ) { $newest = $DateTimeValue }
         if ( $elapsedtime.elapsed.TotalSeconds -gt $tick ) {
          $line=$line.Trim()
          if ( $line.Length -gt 48 ) {
           $line="[...]"+$line.substring($line.Length-48)
          $line="$([char]13)Parsing > $($linenumber) ($(($reader.BaseStream.Position/$reader.BaseStream.length).tostring("P1"))) - $line"
          write-host $line.PadRight($LastLineLength) -NoNewLine
          $LastLineLength = $line.length
          $tick=$tick+$refreshrate      
        } until ($filesdone -or $reader.endofstream)
       finally {
        $reader.Close()
       $line=$($([string][char]13)).padright($lastlinelength)+$([char]13)
       write-host $line -NoNewLine
      $writer.Write("`"$file`"")
      foreach ( $HeaderParam in $HeaderParams.GetEnumerator() | Sort-Object Name ) {
       $name = "$(removekey $HeaderParam.Name)"
       if ( $results[$name] ) {
        $writer.Write(",$($results[$name])")
       } else {
        if ( $ErrorFooter ) {
         #placeholder
        } elseif ( $HeaderParam.Value -eq "counts" ) {
         $writer.Write(",,,,,,")
        } else {
         $writer.Write(",")
      if ( $ErrorFooter ) {
       $tmp = $($ErrorFooter -join "").substring(20)
       $tmp=$tmp.substring(0,$tmp.indexof(")")+1)+","+$tmp
       $writer.write(",,$tmp")
      } elseif ( $fp ) {
       $writer.write(",$LineCount,$($newest.ToString('dd/MM/yyyy hh:mm:ss'))")   
       foreach ( $FileResult in $FileResults.GetEnumerator() ) {
        $writer.write(",$($FileResult.Name): $($FileResult.Value);")
      $writer.WriteLine()
     } else {
      write-host -foregroundcolor darkgray "$($file.name) is not recognised as a RoboCopy log file"
    write-host "$filecount files scanned in $($elapsedtime.elapsed.tostring()), $($ProcessCounts["Processed"]) complete, $($ProcessCounts["Error"]) have errors, $($ProcessCounts["Incomplete"]) incomplete"
    write-host  "Results written to $($writer.basestream.name)"
    $writer.close()
    If you have any other questions, please feel free to let me know.
    If you have any feedback on our support,
    please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • How to Open or load the swf file only in Java application

    Hai.,
         How I Secure my Flash SWF files(AS2 and AS3).?
         The SWF files are only work through java application. When the java call the swf file that time only it will work otherwise it won't work including browsers also..

    I attached the file to this post. It would be great if you could send me the pdf version of the block diagram. It's not totally finished, but that doesn't matter, I can complete it in school.
    Thank you, really, thank you.
    I know that this is not the purpose of this forum, but it was the easiest solution for my problem.
    Attachments:
    Programma transportmiddel.vi ‏129 KB

  • Parse a log file...

    Hi All,
    1. I want to parse the content of log file, but when I open the log file it does not show me field names .
    it starts with row containing the contents directly, where i want to read and process only three fields randomly.
    I have written the code that works on IIS logs, the log i want to parse having field separator ' ' as single white space.
    2. Some of log files are zipped, so I am unable to open and read them. so that I can parse them.
    can any one have any clue or code that help me out.
    thanks!

    bhatnagarudit wrote:
    Hi All,
    1. I want to parse the content of log file, but when I open the log file it does not show me field names .
    it starts with row containing the contents directly, where i want to read and process only three fields randomly.
    I have written the code that works on IIS logs, the log i want to parse having field separator ' ' as single white space.
    2. Some of log files are zipped, so I am unable to open and read them. so that I can parse them.
    can any one have any clue or code that help me out.
    thanks! Here is a suggested algorithm .. (I don't want to write the code for you :-))
    You have the following format.
    314159b66967d86f031c7249d1d9a8024.. mybucket +[04/Aug/2006:22:34:02 +0000]+ 72.21.206.5 314159b66967d86f031c724... 3E57427F33A59F07 REST.PUT.OBJECT* /photos/2006/08/puppy.jpg +"GET /mybucket/photos/2006/08/puppy.jpg?x-foo=bar"+ 200 NoSuchBucket 2662992 3462992 70 10 "http://www.amazon.com/webservices" "curl/7.15.1"
    Read the file in, go thru lines one by one. For each line,
    1. Get the content in the first square brackets. Regular Expression: [&].
    2. From there, get the fourth (4th) word separated by space.
    3. From there, get the content in the first pair of double quotes. Regular Expression: \"&\".

  • Configure Log File for each web application deployed in weblogic server usi

    Hi All,
    How do I configure Log4J to log separately for each web application? i.e. Assuming, I have a web application "AWeb" and a web application "BWeb". I need a log file to be created for AWeb Separately and BWeb Separately. i.e. All the log information for "AWeb" web application will be stored in AWeb.log and all the "BWeb" web application will be stored in BWeb.log
    Do you have any sample code and configuration details for the above-mentioned requirement?
    Thanks in Advance,
    C R Baradwaj

    You do not need to do anything strange, just use log4j the usual way with the exception that you do not need to init log4j (this is not necesary when using a log4j.xml.)
    A minimal sample of a log4j.xml is
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.SimpleLayout"/>
    </appender>
    <root>
    <priority value ="debug" />
    <appender-ref ref="ConsoleAppender"/>
    </root>
    </log4j:configuration>
    You just have to be sure that you have different log4j.xml in your classpath for different web applications.
    Regards,
    LG

  • Add email subject to maillog (sendmail log file)

    I need to add the email subject to sendmail (8.13.8+Sun). I understand I can do that in the sendmail.cf How can I do this for both the local.cf and sendmail.cf, and even the submit.cf so I can see the subject in all the maillog entries.
    This is a solaris 10 server. I found 2 of the same suggestions that did not work.
    I added this to my sendmail.mc file and rebuilt but the subject did not appear in the logs.
    LOCAL_CONFIG
    Klog syslog
    HSubject: $>Log_Subject
    LOCAL_RULESETS
    SLog_Subject
    R$* $: $(log Subject: $1 $) $1
    Thanks

    I got this to work. I had to link both local.cf and sendmail.cf to the resulting file.
    LOCAL_CONFIG
    Klog syslog
    HSubject: $>+CheckSubject
    LOCAL_RULESETS
    SCheckSubject
    R$* $: $(log Subject: $1 $) $1

Maybe you are looking for

  • Can I connect to a network drive on powerup/login?

    I am trying to automate backups with psyncx, and want to specify a network drive which sits on an old networked pc's usb port. At the moment, I have to go in finder, click on network, get to the destination drive I want and then it shows up in finder

  • Tip of head phones broke off and is stuck in the audio jack.

    I plugged in my head phones and the tip of the part that plugs in to the audio jack broke off and is know stuck in there. How do I get it out?

  • Can i use sql server express 2008, 2012, and 2014 for commercial purpose?

    Good day, I saw that the sql server express 2005 can be used for commercial purpose without buying additional license https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8df18025-fc2b-43c2-8476-532336ff09e3/sql-server-express-for-commercial-use?

  • Templates without Dreamweaver

    I'm trying to use the new Contribute CS4 to see if I can build and use templates for client websites without the use of Dreamweaver. This is probably a very elementary question, but can this be done and if so could I get a little jump start on method

  • X6 Bluetooth issues

    I have an Nokia X6 which I connect to both my laptop and car (Blaupunkt Hamburg stereo) for hands free, sometimes the bluetooth 'locks out' it won't connect to either at all, yet if I turn the phone off and on it will then connect to either/both just