search for words, if found, tell me

Discussion in 'Scripting' started by andrea, Nov 10, 2005.

  1. andrea

    andrea Guest

    I have lot of NTbackup logs. want to 'read' these files, and if
    they contain specified words ('error' or 'in use' [bad backup])
    send me an email.

    in few words: search for a word, if found, tell me

    thanks in advance for all help, and sorry for bad english

    andrea, Nov 10, 2005
    1. Advertisements

  2. You can make a script that after the backup, checks the logs by using

    Type LogName.log | findstr "Text To Search"

    (try findstr /? for more options)

    to do the mailing you could use a script from the scriptcenter or a
    freeware tool like blat.exe

    gr /\/\o\/\/
    /\\/\\o\\/\\/, Nov 10, 2005
    1. Advertisements

  3. andrea

    andrea Guest

    \\/\\o\\/\\/ thanks for reply,
    mailing in vbs is not a problem for me. The question is
    a function that find and tell me only specified words.

    list of function/syntax i need:
    - open text file
    - read line per line the specified file
    - recognize the 'bad' words (from an array of words)
    - aliment a variable with value

    i know that my bad english is an obstacle,
    thank you all


    andrea, Nov 11, 2005
  4. "\\/\\o\\/\\/" gave you a batch command to do this, namely:

    Type LogName.log | findstr "Text To Search"

    but that needs to be followed with something to detect whether or not the
    string was found. Also, you seem to be interested in log files that contain
    either "error" or "in use", which he did not mention.

    You could try something like this:

    findstr /i /c:"error" /c:"in use" LogName.txt
    if errorlevel 1 (
    echo/no errors in log file
    ) else (
    echo/errors found in logfile
    rem send message

    Of course, if the log file lists filenames, there might be a file whose name
    contains the string "error", so you can expect some false positives.


    Al Dunbar [MS-MVP], Nov 12, 2005
  5. nice solution,

    As his question was a bit generic (language / precise string, etc.), I
    just wanted to get him going.

    (I think give an example where you stand, stating the problem as narrow
    as possible and naming the language you work with / most familiar with,
    will help to get a more exact answer back)

    if the rest is in VBscript (as he did say mailing in VBscript is no
    problem), you also read the file in VBscipt, then you can do the finding
    with a RegEx what will give a lot of power in formatting the message.

    if so let me know I will post an example.

    gr /\/\o\/\/
    /\\/\\o\\/\\/, Nov 12, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.