Find the answer to your Linux question:
Results 1 to 3 of 3
Hello Helpfull Members, When ever C program exectues it produces error or executes sucessfully. If it produces error i am redirecting the error to a file error.log . I want ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    2

    Smile Can a file notify(signal or invock) a program ,if yes how?


    Hello Helpfull Members,

    When ever C program exectues it produces error or executes sucessfully. If it produces error i am redirecting the error to a file error.log. I want a Signal (notification) to be generated as soon as a write action takes place on error.log, this signal should invoke another program say, Parser.c which will read the error.log copy into buffer and clear the contents of log file.

    Is it possible that a file generates a signal to invoke another program if yes then how can we achive it programitacally.

    Kindly help me with this problem.
    thanks in advance
    Last edited by linuxstartup2012; 05-07-2012 at 07:21 AM. Reason: correcting the sentence

  2. #2
    Just Joined!
    Join Date
    May 2012
    Posts
    4
    I'm not exactlly sure what you need.

    So you have program A running. If find an error you pipe it to error.log. So you want as soon as you write something into error.log for some program B to start reading it?
    Why don't you just, after your done writing to errror.log call another function that forks your process and usses the system function on your B exectuable.

    See this for more details on fork and system: gidforums.com/t-3369.html

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758
    File events can be noticed via inotify . Take look at this Monitor Linux file system events with inotify

    HTH
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

Posting Permissions

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