1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 8] 8.2 Magic Scripts</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:35:51Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch08_01.html" TITLE="8.1 Supporting Programmers"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 8.1 Supporting Programmers" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38<A CLASS="chapter" REL="up" HREF="ch08_01.html" TITLE="8. Additional Samba Information "> 39Chapter 8<br> 40Additional Samba Information </a></font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 41<A CLASS="sect1" HREF="ch08_03.html" TITLE="8.3 Internationalization"> 42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 8.3 Internationalization" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 43</div> 44<blockquote> 45<div> 46<H2 CLASS="sect1"> 47<A CLASS="title" NAME="ch08-79987"> 488.2 Magic Scripts</a></h2><P CLASS="para">The following options deal with <I CLASS="firstterm"> 49magic scripts</i> on the Samba server. 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. See <A CLASS="xref" HREF="ch08_02.html#ch08-33693"> 50Table 8.2</a> for more information. </p><br> 51<TABLE CLASS="table" BORDER="1" CELLPADDING="3"> 52<CAPTION CLASS="table"> 53<A CLASS="title" NAME="ch08-33693"> 54Table 8.2: Networking Configuration Options </a></caption><THEAD CLASS="thead"> 55<TR CLASS="row" VALIGN="TOP"> 56<TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 57<P CLASS="para"> 58Option</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 59<P CLASS="para"> 60Parameters</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 61<P CLASS="para"> 62Function</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 63<P CLASS="para"> 64Default</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 65<P CLASS="para"> 66Scope</p></th></tr></thead><TBODY CLASS="tbody"> 67<TR CLASS="row" VALIGN="TOP"> 68<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 69<P CLASS="para"> 70<CODE CLASS="literal"> 71magic script</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 72<P CLASS="para">string (fully-qualified filename)</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 73<P CLASS="para"> 74Sets the name of a file to be executed by Samba, as the logged-on user, when closed.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 75<P CLASS="para"> 76None</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 77<P CLASS="para"> 78Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 79<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 80<P CLASS="para"> 81<CODE CLASS="literal"> 82magic output</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 83<P CLASS="para"> 84string (fully-qualified filename)</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 85<P CLASS="para"> 86Sets a file to log output from the magic file.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 87<P CLASS="para"> 88<EM CLASS="emphasis"> 89scriptname.out</em></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 90<P CLASS="para"> 91Share</p></td></tr></tbody></table><DIV CLASS="sect2"> 92<H3 CLASS="sect2"> 93<A CLASS="title" NAME="ch08-pgfId-958578"> 948.2.1 magic script</a></h3><P CLASS="para"> 95If the <CODE CLASS="literal"> 96magic</code> <CODE CLASS="literal"> 97script</code> 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 <CODE CLASS="literal"> 98[accounting]</code>:</p><PRE CLASS="programlisting"> 99[accounting] 100 magic script = tally.sh</pre><P CLASS="para"> 101Samba continually monitors the files in that share. If one by the name of <EM CLASS="emphasis"> 102tally.sh</em> 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 <CODE CLASS="literal"> 103#!</code> directive at the beginning of the file to indicate under which shell the script should run.</p></div><DIV CLASS="sect2"> 104<H3 CLASS="sect2"> 105<A CLASS="title" NAME="ch08-pgfId-958584"> 1068.2.2 magic output</a></h3><P CLASS="para"> 107This option specifies an output file that the script specified by the <CODE CLASS="literal"> 108magic</code> <CODE CLASS="literal"> 109script</code> option will send output to. You must specify a filename in a writable directory:</p><PRE CLASS="programlisting"> 110[accounting] 111 magic script = tally.sh 112 magic output = /var/log/magicoutput</pre><P CLASS="para"> 113If this option is omitted, the default output file is the name of the script (as stated in the <CODE CLASS="literal"> 114magic</code> <CODE CLASS="literal"> 115script</code> option) with the extension <EM CLASS="emphasis"> 116.out</em> appended onto it. </p></div></div></blockquote> 117<div> 118<center> 119<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 120<TR> 121<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 122<A CLASS="sect1" HREF="ch08_01.html" TITLE="8.1 Supporting Programmers"> 123<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 8.1 Supporting Programmers" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 124<A CLASS="book" HREF="index.html" TITLE=""> 125<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 126<A CLASS="sect1" HREF="ch08_03.html" TITLE="8.3 Internationalization"> 127<IMG SRC="gifs/txtnexta.gif" ALT="Next: 8.3 Internationalization" BORDER="0"></a></td></tr><TR> 128<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 1298.1 Supporting Programmers</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 130<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 131<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 1328.3 Internationalization</td></tr></table><hr noshade size=1></center> 133</div> 134 135<!-- End of sample chapter --> 136<CENTER> 137<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 138<A HREF="http://www.oreilly.com/"> 139<B>O'Reilly Home</B></A> <B> | </B> 140<A HREF="http://www.oreilly.com/sales/bookstores"> 141<B>O'Reilly Bookstores</B></A> <B> | </B> 142<A HREF="http://www.oreilly.com/order_new/"> 143<B>How to Order</B></A> <B> | </B> 144<A HREF="http://www.oreilly.com/oreilly/contact.html"> 145<B>O'Reilly Contacts<BR></B></A> 146<A HREF="http://www.oreilly.com/international/"> 147<B>International</B></A> <B> | </B> 148<A HREF="http://www.oreilly.com/oreilly/about.html"> 149<B>About O'Reilly</B></A> <B> | </B> 150<A HREF="http://www.oreilly.com/affiliates.html"> 151<B>Affiliated Companies</B></A><p> 152<EM>© 1999, O'Reilly & Associates, Inc.</EM> 153</FONT> 154</CENTER> 155</BODY> 156</html> 157