Next Previous Contents

5. Scripts

5.1 Setup Command (AKA preexec)

This option specifies a command to be run whenever the service is connected to. It takes the usual substitutions.

An interesting example is to send the users a welcome mes­ sage every time they log in. Maybe a message of the day? Here is an example:

        csh -c 'echo \"Welcome to %S!\" | \ /usr/local/samba/bin/smbclient
         -M %m -I %I' &
        

Of course, this could get annoying after a while :-)

See also Cleanup Command.

Default: None (No command executed)

Example: echo \"%u connected to %S from %m (%I)\" >> /tmp/log

5.2 Setup Command (root)

This is the same as Setup Command except that the command is run as root. This is useful for mounting filesystems (such as cdroms) before a connection is finalised.

5.3 Cleanup Command

This option specifies a command to be run whenever the service is disconnected. It takes the usual substitutions. The command may be run as the root on some systems.

An interesting example may be do unmount server resources:

        /sbin/umount /mnt/cdrom
        

See also Setup Command

Default: None (No command executed)

Example: echo \"%u disconnected from %S from %m (%I)\" >> /tmp/log

5.4 Cleanup Command (root)

This is the same as Cleanup Command except that the command is run as root. This is useful for unmounting filesystems (such as cdroms) after a connection is closed.

5.5 Magic script

This parameter specifies the name of a file which, if opened, will be executed by the server when the file is closed. This allows a UNIX script to be sent to the Samba host and executed on behalf of the connected user.

Scripts executed in this way will be deleted upon completion, permissions permitting.

If the script generates output, output will be sent to the file specified by the magic output parameter (see above).

Note that some shells are unable to interpret scripts containing carriage-return-linefeed instead of linefeed as the end-of-line marker. Magic scripts must be executable "as is" on the host, which for some hosts and some shells will require filtering at the DOS end.

Magic scripts are EXPERIMENTAL and should NOT be relied upon!

Default: None. Magic scripts disabled.

Example: user.csh


Next Previous Contents