11.2 Magic Scripts

   

Magic scripts are a method of running programs on Unix and redirecting the output back to the SMB client. These are essentially an experimental hack. However, some users and their programs still rely on these two options for their programs to function correctly. Magic scripts are not widely trusted, and their use is highly discouraged by the Samba Team.

11.2.1 Magic Script Options

Table 11-2 lists the options that deal with magic scripts on the Samba server.

Table 11-2. Magic script options

Option

Parameters

Function

Default

Scope

magic script

string (filename)

File to be executed by Samba, as the logged-on user , when closed

None

Share

magic output

string (filename)

File to log output from the magic file

scriptname.out

Share

11.2.1.1 magic script

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 CRLFs. In addition, you need to use the #! directive at the beginning of the file to indicate under which shell or interpreter the script should run, unless the script is for the default shell on your system.

11.2.1.2 magic output

This option specifies an output file to which the script specified by the magic script option will send output. You must specify a filename in a writable directory:

 [accounting]     magic script = tally.sh     magic output = /var/log/magicoutput 

If this option is omitted, the default output file is the name of the script (as stated in the magic script option) with the extension .out appended onto it.

   


Using Samba
Using Samba: A File and Print Server for Linux, Unix & Mac OS X, 3rd Edition
ISBN: 0596007698
EAN: 2147483647
Year: 2003
Pages: 475

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net