FCM: dead-simple File Change Monitor

Here's a simple change monitor I wrote in C. It takes as arguments a list of files and associated commands; when the file changes, its command is executed.
Example:
$ fcm -f some-file.txt -e 'echo some-file.txt changed!' \
> -E ad -f some-file-2.txt -e 'echo some-file-2.txt changed!'
'-E ad' preceding the second file causes FCM to examine both attribute change and data change.
AUR: http://aur.archlinux.org/packages.php?ID=35877
Mercurial repo: http://peasantoid.org:1024/fcm
Last edited by Peasantoid (2010-03-24 23:50:06)

thomasd wrote:
Hi Peasantoid,
I try to use fcm to print mail by saving a mail to a specific file while having this running:
fcm -f ~/operamail.mbs -e "iconv -t iso8859-1 ~/operamail.mbs | a2ps -=mail -Pprinter"
However, fcm starts two processes, thus I get two printouts:
a2ps: unknown encoding `utf-8', ignored
[stdin (Mail Folder): 2 pages on 1 sheet]
a2ps: unknown encoding `utf-8', ignored
[stdin (Mail Folder): 2 pages on 1 sheet]
request id is printer-132344 (1 file(s))
[Total: 2 pages on 1 sheet] sent to the printer `printer'
request id is printer-132345 (1 file(s))
[Total: 2 pages on 1 sheet] sent to the printer `printer'
Both hardcopies show all text, so my first assumption that the file changes twice during writing is obviously not true. Can I overcome this in some way?
Hrm. It may have something to do with me using inotify's IN_MODIFY instead of IN_CLOSE_WRITE. Run this in the source tree:
sed -i s/IN_MODIFY/IN_CLOSE_WRITE/ fcm.c
Then recompile and post back on whether it works.
# edit - clarity
Last edited by Peasantoid (2010-04-23 07:39:19)

Similar Messages

  • How to monitor file changes

    all experts.........
    i'm wondering if it is possible to monitor the file changes and load updated file contents dynamically for a java application. i have some simple txt file. i'm taking my input data from these files for the simulation. during the sim some of these data will be changed and i need to take these new data as a input for the next step. any idea would help me a lot. thanksssssssss in advance.
    arun

    There's a few ideas in [url http://forum.java.sun.com/thread.jsp?forum=4&thread=431288]this thread

  • Need to monitor any file change in the system, in real time

    Hi,
    I am running a program that I suspect may be doing changes in the filesystem, but I do not know which ones. I would like to know if there is a daemon/program that could help me monitor those changes. I tried AIDE, however, it works by creating a database of checksums for each file and does not report in real time potential changes. I would rather use a program that logs changes and timestamp them. Furthermore, AIDE is not useable with /var files, since there are many of them and they change so often. Is there another good solution?
    Alternatively I would like to run the program with monitoring. For instance, run the process as:
    monitor_program my_program_to_monitor logfile
    This would dump in logfile what my_program_to_monitor does to the filesystem.
    Thanks in advance.
    Last edited by zebulon (2011-08-24 15:44:10)

    no, at least with inotifywait, it is not possible. once you know what file is being changed you can use "lsof" to see what process have opened that file.
    i tried the following to search lsof output first thing when inotifywait finds a file change.
    file=$(inotifywait -r /home/mang/watch --format %w | sed 's/.$//'); lsof | grep $file
    while in another terminal running "vi /home/mang/watch/test"
    the output is:
    zsh 12574 mang cwd DIR 254,11 4096 4723089 /home/mang/watch
    vi 16790 mang cwd DIR 254,11 4096 4723089 /home/mang/watch
    try it!

  • Problem in Simple file to file scenario

    Hello,
    I am new to SAP PI 7.3. I am doing a simple file to file scenario. The source file contains key,name,id,gender,role & location field. I have done a simple mapping to create the same file in the target side. I have done all the configuration in ESR & ID.
    But the problem is that in the target file ( Destination File ) i am getting only key field and the other fields are missing.
    Note: In communication channel monitoring, the communication channel is functioning properly and in message monitor also, the status is 'delivered'.
    The source payload also contains all the fields correctly. In message mapping (in ESR) also, the target payload is also generating correctly. But in the destination file I am getting the key field only and the rest fields are missing.
    Can you please suggest me what to do and where is the problem?
    Thanks & Regards,
    Moumita

    Hello,
    Do u have any MT name above Record node? If yes, then u have to change ur structre little bit. Check my reply in the thread pasted below.
    problems with MessageTransformBean SimpleXML2Plain
    BTW, if i am not wrong Iñaki has also suggested the same.
    Thanks
    Amit Srivastava

  • CPS Simple File Deployer corrupts XLSX and DOCX files when copying to server. Solutions?

    When Contribute Publishing Service Simple File Deployment copies XLSX and DOCX files from our staging server to the live production web server, it is corrupting them.  The resulting file on the live web server is a few bytes different in size.  I published a 9015-byte docx file to our staging server using Dreamweaver (or Contribute).  The resulting file on the staging server opens correctly and remains 9015 bytes.  Then, using CPS Simple File Deployer, I deployed the file from our staging server to our live web server.  The resulting file on the live web server is 9017 bytes, and it won't open.  Something similar happens with XLSX files.  It works fine with XLS, DOC, Html etc.  Well, there is an issue with dependent files unless I synchronize with Dreamweaver, but that's another story.
    Once File Deployer has corrupted the files, opening them brings a message, such as "Excel has found unreadable content in filename.xlsx. . . ".  With Word, it says "The Office Open XML file filename.docx cannot be opened because there are problems with the contents . . . The file is corrupt and cannot be opened."  Sometimes the docx files can be recovered, but that doesn't help. 
    When I take the same original docx file and put it on the web server with an FTP program, it remains 9015 bytes and opens successfully on the live web server.
    For several reasons, such as many users updating the website with Adobe Contribute and not let them use FTP directly to the live server, we need to keep the staging server and use File Deployer (or something) to deploy the changed files from the staging server to the live website.
    I read somewhere that the programming code the uploads files can have problems and fail to work properly with Office 2007 files.  I don't have access to CPS's core.ctc and deployfile.cfc files, and I don't have Cold Fusion. 
    Any suggestions?
    Dean

    Try: 
    Open My Computer.
    Open the Tools menu and choose Folder Options...
    Select the File Types tab.
    Select the extension (for example DOC, or XLS) of the file that is slow to open.
    In the Details section, click [Advanced], and another dialog box will open. 
    In the Actions section, click Open then click [Edit...], and another dialog box will open.
    http://windowssecrets.com/forums/showthread.php/149672-10-9-2012-Updates-and-very-slow-opening-of-Office-files
    KR

  • Simple (File-XI-File)scenario

    Hi,
    I am going through Venkat Donela's simpe (File-XI-File)scenario Part1 and part2.
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1345. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    But my XI did not pick up the input file. I use SXMB_MONI and look at the message monitoring. It says "No message has been selected'. I don't see "adapter monitoring" option on my "Runtime WorkBench".
    Is there anybody could tell me how I can monitor the scenario execution? I checked the every step states in Venkat Donela's sample.
    Any comments and advice will be highly appreciated.
    Meiying

    Hi,
    The best way to check if your file is being picked is to set the "Processing Mode to Delete"....So then you will know if your file is actually being picked...
    Also go to Message Monitoring of RWB and check for the status. Because if you have content conversion problems then it will show there in MDT(Message Display Tool under Message Monitoring).
    And if you are using NFS connection for Sender File Adapter, try to check for the checkBox "ReadOnly Files".
    Pls go through the explanation of a simmilar scenario that i have explained below and compare it with what you have done..
    Please go thru the following links and clear all your doubts.
    Communication channel:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/65/b11c409ce22402e10000000a1550b0/frameset.htm">Assigning Communication Channels</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2b/d5653fd1d3b81ae10000000a114084/content.htm">Communication Channel</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm">Configuring the Sender File/FTP Adapter</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm">Configuring the Receiver File/FTP Adapter</a>
    Receiver agreement:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/56/02e63f48e58f15e10000000a155106/frameset.htm">Receiver Agreement</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/c1/5194426b44c56ae10000000a155106/frameset.htm">Creating a Receiver Agreement</a>
    Sender agreement:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/db/73e03fc2269615e10000000a155106/frameset.htm">Sender Agreement</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/22/522041cfb7f423e10000000a155106/frameset.htm">Creating a Sender Agreement</a>
    For detailed info, I would suggest that you go through these weblogs:
    <a href="/people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1">Introduction to simple(File-XI-File)scenario for Starters</a>
    <a href="/people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2">Introduction to simple (File-XI-File)scenario for starters part2</a>
    I hope it helps.
    Regards,
    Abhy
    Message was edited by: Abhy Thomas

  • Help with simple file to file BPM scenario

    Hi Gurus,
    I am doing simple file to file BPM scenario.
    I am getting an error in SXI_CACHE with status code 99.
    I activated the business process then status code changed to 2.
    When i tried to activate the process again i am getting prompted to enter access key details.
    Is there any other way to get rid of the error i.e., to get the status code to zero with giving access key details.Sample access key details are also greatly appreciated.

    Hi Bhavesh,
    I tried doing that but of no use.
    I registered at https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/minisap/minisap.htm
    and got a mail with details.I was actually looking for access key details in the mail from sap.The details in the mail contains License key but not access key .Are the both access key and license key same?

  • Simple Text Changes Won't Upload to Server?

    I have created a simple HTML e-mail signature in Photoshop, slicing and inputed all information in the "Slice Option" dialogue box, including the URL link for each social media platform button. I imported it into Dreamweaver, uploaded the files to my server and it works perfectly! Here is the issue I am having: I needed to make a simple link change to one of the buttons. I tried changing the link in Dreamweaver. Did not work! I tried changing the link in Photoshop, making the edit in the slice and re-saving the file and uploading to the server via Dreamweaver. Did not work. I eventually had to redo all the slices, renaming them something different; input to Dreamweaver under a different file name, do what i had to do, and then upload to my server. Everything worked perfect! Why? Why can't I just make a simple text change in Dreamweaver, uploaded it, and it works?! I feel like it is a cache issue, but i have no idea.
    Anybody have a solution?
    Frustrated Creative Cloud Subscriber
    Michael Salewych

    Open browser and hit Ctrl+R to refresh.  Or clear your browser's cache from the Tools menu.  In Firefox, Tools > Options > Advanced.
    Nancy O.

  • Simple File Sharing in Windows XP

    The simple file sharing that is automatically turned on in XP is
    causing some problems with programs we run. An administrator can turn
    it off, but as soon as any user logs onto the machine, the setting in
    re-enabled. It would seem that the novell client or more likely Group
    Policies set through the Workstation manager is turning it back on but
    we cannot find where to change the setting. What can we do to turn
    simple file sharing off and have it stay off for all users.
    Thanks
    Matthew McNicholas
    PEDCO E & A Services Inc.

    It looks like we had that setting correct the whole time except the
    Security Setting check box was not checked. We're getting close! For
    administrators it works great, simple file sharing is turned off when
    they logon. However, the power users are still not able to change this
    setting I think because of security access (when they logon the setting
    never changes but the same change was made in thier policy package as
    the admin package).
    I thought maybe I could add the power users to another group to grant
    them access to change that setting, but I don't want to give them
    access they don't need. I saw that in C1 you can create custom groups
    though dynamic local users. I went to add privileges to a custom
    group, but there are no descriptions of what each privilege actually
    gives the user. I could not find an explaination on novell's website
    or in the help file. This may not work at all but right now I'm in a
    trial and error situation. If anyone knows what privilege to add or
    where to find descriptions of them, please let me know.
    Or if you happen to know another reason why administrators might work
    and power users don't, please let me know that also.
    Thanks
    Matthew McNicholas
    PEDCo E & A Services
    Rolf Lidvall wrote:
    > > One of the web pages you refered to says the
    > > following..."ForceGuest is enabled by default, but can be disabled
    > > on Windows XP Professional by disabling the local security policy
    > > Network Access: Force Network Logons using Local Accounts to
    > > Authenticate as Guest". I cannot find this setting in the mmc.
    > > Does anyone know how to add it or where to find it?
    >
    > Matthew, great, I should read my own tips ;-)
    >
    > I did not know about this setting, I was wrong, it IS
    > a Group Policy setting. I am at home now and have only
    > a Swedish WinXP, so it might not be the exact English:
    > Edit a WS Group Policy in C1, check Security Settings, go to:
    > Computer Configuration -> Security Settings -> Local Policies
    > -> Security Options ->
    > Network Access: Sharing and Security Model for Local Accounts
    > (or something similar to that)
    > Duuble-Click on that and now you will get a Drop-Down-List
    > with the setting.
    >
    > Does that work?
    >
    > Regards
    > Rolf Lidvall
    > Swedish Radio (Ltd)

  • Maown - file system monitor for shared group directories

    Maown Info Page
    I needed a way to manage ownership and permissions of files in a shared directory. ACLs and "chmod g+s" alone were not enough so I wrote maown.
    Maown is a file system monitor written in C. It uses inotify to recursively watch a directory tree for file creation and attribute modification. It automatically chowns files to user:group and adjusts group permissions to match user permissions.
    The package includes a daemon with a simple configuration file. Each line in the configuration file specifies a user, a group and a list of directories to monitor:
    <user> <group> <directory> [<directory>...]
    Last edited by Xyne (2012-05-21 02:35:24)

    Maown has been replaced with Autochown.

  • DW8: opening an existing file changes it

    The coding is very suss, I admit it: these are sites built originally in Drumbeat 2000 and imported into DW8. An enormous amount of manual work had to be done on them after the importing, but at least they worked.
    Every time I open any of the .html files within any of these sites, an asterisk appears next to the file's name tab, and closing it without having done anything whatsoever to it results in the standard "do you want to save changes?" message.
    Is there a simple explanation, please?

    I wish I could say "Aha! - that's it!", because that would mean I have the knowledge behind what's going on.
    It was my late husband who undertook the enormous burden of importing three travel sites I'd made in Drumbeat 2000 into a portal site he created in Dreamweaver 8, and spending uncountable hours fiddling with them to make them at least sound enough to be seen.
    Still, I would guess you're right, inasmuch as the sites are indeed still so full of .html errors -- he stopped wasting his time on the once he'd got them to lock-down, as it were: the 'import' command was always a piece of gross exaggeration -- that I'd have to sit here opening and closing 'em for weeks before DW8 got any kind of feeling it'd dealt with them all.
    I think your response tells me, at least, that what's going on doesn't mean anything frightening...
    Whereas it had alarmed me, this business of the files changing upon being opened, it's now just something to make me sigh; but I can go ahead and make little corrections, here and there...
    I'm going to recreate them all, one day.
    Thank-you very much indeed for your input.

  • File change notification

    Is there any way to obtain a notification in form of a signal or callback invokation, when the selected file is being modified?
    More precisely, I need a mechamism to implement a "tail -f" monitoring solution without the use of reads on timeouts.
    Sleeping even for a sec is not appropriate for a near real-time monitoring system. Therefore, I need a more robust approach.
    I've not found anything that may provide a means to such a trick so far. Moreover, what is frustrating is that tail command is implemented with the use of a sleep-read sequence.
    Sincerely
    Vladimir

    >
    Is there any way to obtain a notification in form of a
    signal or callback invokation, when the selected file
    is being modified?
    More precisely, I need a mechamism to implement a
    "tail -f" monitoring solution without the use of reads
    on timeouts.     If you are truely just interested in seeing
    if the file changes use stat(2) and get the file size.
         If you truly want to read the file as it
    is being writen to, you can open it, seek to somewhere
    near the end and do reads. You are not using the
    shell as you would with tail -f, you are just a
    separate process reading a file that is being appended
    to by another process. I assume that the file being
    created is opened for sequential access and the writer
    is appending to its end. The other process wants
    to read from somwhere else in the file, prehaps at
    a leisurely pace.
    Sleeping even for a sec is not appropriate for a near
    real-time monitoring system. Therefore, I need a more
    robust approach.
    I've not found anything that may provide a means to
    such a trick so far. Moreover, what is frustrating is
    that tail command is implemented with the use of a
    sleep-read sequence.
    Sincerely
    Vladimir

  • T61 XP-Pro simple file sharing. T61 can't browse its own shared folders nor can Workgroup PC's

     T61 simple file sharing.
    The shared folders can be seen in "Workgroup" by the T61 and other intranet "Workgroup" PC's but not browsed. This is the error message:
    "\Thinkpad\desktop  is not accessible.  You might not have permission to use this network resource.  Contact the administrator of the server to find out if you have access permissions.  The network path was not found."
    What permissions or security settings need set?
    Thanks,  Jim Martin  Columbus IN
    Message Edited by jbaaremartin on 07-18-2008 11:12 PM
    Message Edited by jbaaremartin on 07-18-2008 11:12 PM
    Solved!
    Go to Solution.

    When I tried to map a drive  I also got " Not enough server storage is available to process this command."
    This registry change fixed it:
    http://support.microsoft.com/default.aspx?scid=kb;en-us;177078
    I think this T61 6459 must have come with Norton anti-virus and I think I removed it when new in June.  When I started using it recently I received the "Unable to load Symevent" error opening cmd.exe and fixed it with the Symevent update...Without Norton do I even need C:\PROGRA~1\Symantec\S32EVNT1.DLL..?  Anybody opine?
    Anyway I can now browse my shares locally and on the intranet. :

  • Does simple file and folder sharing on an iMac work with OSX Server?

    Hi There
    I wonder if I should install OSX Server on an iMac wher several users work on the same files and folders.
    My question - before I do something I might regret:
    Does simple file and folder sharing on an iMac within several users really work with the help of OSX Server?
    All I want to be able to do:
    Admin creates a new folder1 and gives it read- and write access for user1 and user2.
    User1 creates a subfolder1 in folder1, and a document1 in subfolder1.
    User2 edits document1. Later Admin edits document1.
    All these simple editing of files and folders (and subfolders) within a main folder should be possible. This is not possible now.
    Is everything clear? I'm not a network specialist or something, I just want to give some co-workers access to some data on my computer without problems.

    So what you need are recursive permissions.
    I suggest you create a group and add user1 and user2 to that group. You can name that group whatever you want, but for now i will call it FSUsers
    Execute this in terminal. Replace FSUsers with your new group
    sudo chmod -R +a "FSUsers allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextat tr,writeextattr,readsecurity,file_inherit,directory_inherit" /Users/Shared/*
    Replace /Users/Shared with the location of your shared folder. Make sure you keep the /* at the end (this allows all subfolders and files to get the same permissions.
    If you need to add people to the share just add them to the FSUsers group, the FSUsers group should should also be allowed in the sharing preferences.

  • After plugging my hard drive on my friend's windows all the files changes to .ink!!!! please help

    I gave my friend who has windows laptop to copy some files from my hard drive WD 1tb. when I plug it into my mac all the files changed to .ink files I can't open them I tried to repair it and didn't work. there are important files on it so any idea please???

    CS5.5 - http://helpx.adobe.com/creative-suite/kb/cs5-5-product-downloads.html
    You can also download the trial version of the software thru the page linked below and then use your current serial number to activate it.
    Be sure to follow the steps outlined in the Note: Very Important Instructions section on the download pages at this site and have cookies enabled in your browser or else the download will not work properly.
    CS5.5: http://prodesigntools.com/adobe-cs5-5-direct-download-links.html

Maybe you are looking for

  • How to reset computer password if I forgot my original password?

    how to reset computer password if I forgot my original password?

  • Why does my cmus look like this?

    It's in a screen session on Leopards terminal. It didn't do this before and I haven't updated anything and I'm confused. If I go to the cmus window, the rest of the screen windows look like that too and when I detach the term looks like that. hrm, it

  • Touch mouse

    i have broke the mouse pad on my laptop and i need to turn it off as it keeps thinking its being used!

  • May have a virus...help please

    So I pay WoW and pretty much like 5 minutes ago i was hacked...i remember accidently going to a weird website and a pop up came up and i knew it wasnt good so i backed out...anyways, im fairly new to macs and i heard that macs rarely if ever get a a

  • Question for analytic functions experts

    Hi, I have an ugly table containing an implicit master detail relation. The table can be ordered by sequence and then each detail is beneath it's master (in sequence). If it is a detail, the master column is NULL and vice versa. Sample: SEQUENCE MAST