CLOSE COMMAND PARAMETER FOR SAMBA This patch adds a 'close command' parameter to samba which runs the specified command when files are closed on a share. The patch can be downloaded from for 2.0.2: http://www.reac.com/samba/2.0.2/samba-closecmd-2.0.2.diff for 2.0.3: the 2.0.2 patch applies without incident to 2.0.3 Apply with GNU patch from inside the samba-2.0.x directory (you should be at the same level as the source and docs directories) with: patch -p1 < PATCHFILE The command takes the normal macro substitutions in addition to %s and %f which will expand to the path and name of the closed file. The path does not include the path of the share, so you may need to give it %p/%s in order to get a full path to the closed file. close command = echo "%u closed %p/%s" >> /tmp/closedfiles.txt Possible uses could be to create a share that serves as drop off point for some automated tasks, doing file format conversions, automated bulk faxing, stuff like that. ---------------------------------------------------------------------------- Hey, there are some things that Windows clients do that may effect the operation of the command specified with close command. Specificly, WinNT sends a close SMB THREE TIMES when writing a file. The best I can make out is that it creates the file and closes it (first time the close command is invoked), the file will have a zero size at this point. Then it opens it to see if it exists and closes it (second time the close command is invoked), it should still have a zero size at this point. I believe that if the open fails, then the Windows client assumes that permissions were invalid to write to the directory. Then it opens it again, fills it with data, and then closes it (third time close command is invoked). Keeping this in mind: > close command = touch %f > > Perfect timing! I hope %f operates correctly here, though... may have problems because the file may get created, and you only want to touch already created files. I think you'd want to use close command = touch -c "%P/%f" so that touch won't create files that don't already exist. From the GNU touch man page: -c, --no-create Do not create files that do not exist. Anyway, you have to remember that the close command may be invoked multiple times during the file creation stage, and that a 'read' close is not different than a 'write' close. In my scripts, I exit if the file that was passed doesn't exist or if it has zero size. If it does exist, I rename it before I operate on it, so when the script is invoked again, I'm only operating on it once. Also, for my uses, I only operate on files that have certain extensions, and my scripts either remove the file all together or rename it (as a sign that it has been processed). ----------------------------------------------------------------------------