If the
magic
script
option is set to a filename and the client creates a file by that name in that share, Samba will run the file as soon as the user has opened and closed it. For example, let's assume that the following option was created in the share
[accounting]
:
[accounting]
magic script = tally.sh
Samba continually monitors the files in that share. If one by the name of
tally.sh is closed (after being opened) by a user, Samba will execute the contents of that file locally. The file will be passed to the shell to execute; it must therefore be a legal Unix shell script. This means that it must have newline characters as line endings instead of Windows CR/LFs. In addition, it helps if you use the
#!
directive at the beginning of the file to indicate under which shell the script should run.