« Previous Next »

Thread: Supress error when no matching files?

Last post 05-18-2007 8:12 PM by LogParser User : DEinspanjer. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 05-18-2007, 4:29 AM

    Supress error when no matching files?

    When the input format is file system, if no files match the pattern, LogParser considers this an error. This is demonstable by the following:

    "C:\Program Files\Log Parser 2.2\LogParser.exe" -i:FS "SELECT path FROM '%WINDIR%\*.xyz'"

    Task aborted.
    Cannot open <from-entity>: Cannot find any file or folder matching
      "C:\WINDOWS\*.xyz"

    Statistics:
    -----------
    Elements processed: 0
    Elements output:    0
    Execution time:     0.67 seconds

    F:\temp>echo %errorlevel%
    2

    Does anyone know of a way to get LogParser to not consider the absence of any matching files as being an error? (Note the example is for illustrative purposes only, so that it can be run by anyone, rather than the actual query that is to be run).

    Thanks.

    David

  • 05-18-2007, 7:16 AM In reply to

    RE: Supress error when no matching files?

    Hrm. Only thing I can think of off the top of my head is to have a dummy file that is always there.
    Something like this worked for me:

    "C:\Program Files\Log Parser 2.2\LogParser.exe" -i:FS "SELECT path FROM C:\tmp\scores.txt, 'C:\tmp\*.xyz' WHERE Path <> 'C:\tmp\scores.txt'"
    Statistics:
    -----------
    Elements processed: 1
    Elements output: 0
    Execution time: 0.08 seconds
  • 05-18-2007, 8:12 PM In reply to

    RE: Supress error when no matching files?

    Thanks Daniel. Your reply got me thinking along a suitable track.

    I was averse to having a "token" file that is known to exist on the basis that one day there may be a need to include the given token file in the results but a variation on your suggestion works for me. Namely, to include within the "from" list a known directory (i.e. '.') and then exclude directories via a check on the attributes, such as:

    "f:\Program Files\Log Parser 2.2\LogParser.exe" -i:FS "SELECT path FROM '%WINDIR%\*.xyz', '.' WHERE substr(attributes,0, 1) <> 'D'"

    Statistics:
    -----------
    Elements processed: 2
    Elements output:    0
    Execution time:     0.78 seconds


    F:\temp>echo %errorlevel%
    0

    Thanks for your response.

    David

Page 1 of 1 (3 items)
Microsoft Communities