Find the answer to your Linux question:
Results 1 to 2 of 2
I am monitoring a log with swatch and cannot figure out how to pull a number from the line I am watching for and insert it into the subject on ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    2

    SWATCH Configuration: Dynamic Subject


    I am monitoring a log with swatch and cannot figure out how to pull a number from the line I am watching for and insert it into the subject on an email.

    For example:
    Line = "I want to pull this number 123456 and put it in the subject of my email sent by swatch"

    I have tried the below and other variations to no avail.

    Code:
    watchfor /I want to pull this number [0-9]{6} and put it in the subject of my email sent by swatch/
         exec echo $0 | mail -s "The number is " $7 email[at symbol]blah.com
    Code:
    watchfor /I want to pull this number [0-9]{6} and put it in the subject of my email sent by swatch/
         mail addresses=email[at symbol]blah.com,subject=The number is $7
    Any help would be most appreciated, thanks.

  2. #2
    Just Joined!
    Join Date
    Mar 2011
    Posts
    2
    It looks like I could use the 'pipe' command

    pipe command[,keep_open]
    Pipe matched lines into command. Use the keep_open option to force the pipe to stay open until a different pipe action is run or until swatch exits.
    But I cannot get this to work ... I haven't found any examples online that work. Has anyone successfully used the pipe command?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •