3 <li><a href="#TWiki CGI and Command Line Scrip"> TWiki CGI and Command Line Scripts</a><ul>
4 <li><a href="#CGI Scripts"> CGI Scripts</a><ul>
5 <li><a href="#General Information"> General Information</a><ul>
6 <li><a href="#CGI environment"> CGI environment</a></li>
7 <li><a href="#Command-line"> Command-line</a></li>
8 <li><a href="#Common parameters"> Common parameters</a></li>
11 <li><a href="#=attach="> attach</a></li>
12 <li><a href="#=changes="> changes</a></li>
13 <li><a href="#=configure="> configure</a></li>
14 <li><a href="#=edit="> edit</a></li>
15 <li><a href="#=login="> login</a></li>
16 <li><a href="#=logon="> logon</a></li>
17 <li><a href="#=manage="> manage</a><ul>
18 <li><a href="#=action=createweb="> action=createweb</a></li>
19 <li><a href="#=action=delete_UserAccount="> action=deleteUserAccount</a></li>
20 <li><a href="#=action=editSettings="> action=editSettings</a></li>
21 <li><a href="#=action=bulkRegister="> action=bulkRegister</a></li>
22 <li><a href="#=action=saveSettings="> action=saveSettings</a></li>
25 <li><a href="#=oops="> oops</a></li>
26 <li><a href="#=passwd="> passwd</a><ul>
27 <li><a href="#=action=changePassword="> action=changePassword</a></li>
30 <li><a href="#=preview="> preview</a></li>
31 <li><a href="#=rdiff="> rdiff</a></li>
32 <li><a href="#=register="> register</a></li>
33 <li><a href="#=rename="> rename</a></li>
34 <li><a href="#=resetpasswd="> resetpasswd</a></li>
35 <li><a href="#=rest="> rest</a><ul>
36 <li><a href="#Invocation Examples"> Invocation Examples</a></li>
39 <li><a href="#=save="> save</a></li>
40 <li><a href="#=search="> search</a></li>
41 <li><a href="#=statistics="> statistics</a></li>
42 <li><a href="#=twiki="> twiki</a></li>
43 <li><a href="#=upload="> upload</a></li>
44 <li><a href="#=view="> view</a></li>
45 <li><a href="#=viewfile="> viewfile</a></li>
48 <li><a href="#Command Line Scripts"> Command Line Scripts</a><ul>
49 <li><a href="#=geturl.pl="> geturl.pl</a></li>
50 <li><a href="#=rewriteshebang.pl="> rewriteshebang.pl</a></li>
51 <li><a href="#=tick_twiki.pl="> tick_twiki.pl</a></li>
59 # <a name="TWiki CGI and Command Line Scrip"></a> TWiki CGI and Command Line Scripts
61 _Programs on the TWiki server performing actions such as rendering, saving and renaming topics._
63 The TWiki scripts are located in the `twiki/bin` and `twiki/tools` directories. This topic describes the interfaces to some of those scripts. All scripts in the `twiki/bin` directory can be called from the CGI ([Common Gateway Interface](http://en.wikipedia.org/wiki/Common_Gateway_Interface)) environment or from the command line. The scripts in the `twiki/tools` directory can only be called from the command line.
65 ## <a name="CGI Scripts"></a> CGI Scripts
67 Details on CGI scripts located in the `twiki/bin` directory.
69 ### <a name="General Information"></a> General Information
71 #### <a name="CGI environment"></a> CGI environment
73 In the CGI environment parameters are passed to the scripts via the URL and URL parameters. Environment variables are also used to determine the user performing the action. If the environment is not set up, the default TWiki user is used (usually `guest`).
75 #### <a name="Command-line"></a> Command-line
77 You **must** be cd'd to the `twiki/bin` directory to run the scripts from the command line. To avoid issues with file permissions, run the scripts as the web server user such as `nobody` or `www`.
79 Parameters are passed using '-name' - for example,
81 $ cd /usr/local/twiki/bin
82 $ save -topic MyWeb.MyTopic -user admin -action save -text "New text of the topic"
84 All parameters require a value.
86 #### <a name="Common parameters"></a> Common parameters
88 All the scripts accept a number of common parameters. The first two components of the URL after the script name are taken as the web and the topic, respectively. Standard URL parameters are:
90 <table border="1" cellpadding="0" cellspacing="0">
92 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
93 <th bgcolor="#99CCCC"><strong> Description </strong></th>
94 <th bgcolor="#99CCCC"><strong> Default </strong></th>
97 <td><code>topic</code></td>
98 <td> If this is set to a URL, TWiki will immediately redirect to that URL. Otherwise it overrides the URL and is taken as the topic name (you can pass Web.TopicName) </td>
102 <td><code>user</code></td>
103 <td> Command-line only; set the name of the user performing the action. Note: this usage is inherently insecure, as it bypasses webserver login constraints. For this reason only authorised users should be allowed to execute scripts from the command line. </td>
107 <td><code>skin</code></td>
108 <td> Overrides the default skin path (see [[Main/TWikiSkins]]) </td>
112 <td><code>cover</code></td>
113 <td> Specifies temporary skin path to prepend to the skin path for this script only (see [[Main/TWikiSkins]]) </td>
118 ### <a name="=attach="></a> `attach`
120 Despite the name, this script doesn't actually attach a file to a topic - for that, use `upload`. This script is part of the transactions sequence executed when a file is uploaded from the browser. it just generates the "new attachment" page for a topic.
122 <table border="1" cellpadding="0" cellspacing="0">
124 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
125 <th bgcolor="#99CCCC"><strong> Description </strong></th>
126 <th bgcolor="#99CCCC"><strong> Default </strong></th>
129 <td><code>filename</code></td>
130 <td> Name of existing attachment (if provided, this is a "manage attachment" action) </td>
131 <td> none (in which case this is a "new attachment" action) </td>
135 ### <a name="=changes="></a> `changes`
137 Shows all the changes in the given web.
139 The `changes` script can receive one parameter:
141 <table border="1" cellpadding="0" cellspacing="0">
143 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
144 <th bgcolor="#99CCCC"><strong> Description </strong></th>
145 <th bgcolor="#99CCCC"><strong> Default </strong></th>
148 <td><code>minor</code></td>
149 <td> If 0, show only major changes. If 1, show all the changes (both minor and major) </td>
154 The main difference between invoking this script and using [[WebChanges]] is that [[WebChanges]] is based on a `%SEARCH%`, while this script reads the `changes` file in each web, making it much faster.
156 **NOTE**: The result from `changes` script and the topic [[WebChanges]] can be different, if the `changes` file is deleted from a web. In particular, in new installations the `changes` script will return no results while the [[WebChanges]] topic will.
158 ### <a name="=configure="></a> `configure`
160 `configure` is the browser script used for inspection and configuration of the TWiki configuration. None of the parameters to this script are useable for any purpose except `configure`.
162 ### <a name="=edit="></a> `edit`
164 The `edit` scipt understands the following parameters, typically supplied by HTML input fields:
166 <table border="1" cellpadding="0" cellspacing="0">
168 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
169 <th bgcolor="#99CCCC"><strong> Description </strong></th>
170 <th bgcolor="#99CCCC"><strong> Default </strong></th>
173 <td><code>action</code></td>
174 <td> Optional. Use the editaction template instead of the standard edit. If action=text, then hide the form. If action=form hide the normal text area and only edit the form. </td>
178 <td><code>onlynewtopic</code></td>
179 <td> If set, error if topic already exists </td>
183 <td><code>onlywikiname</code></td>
184 <td> If set, error if topic name is not a [[Main/WikiWord]]</td>
188 <td><code>templatetopic</code></td>
189 <td> The name of the template topic, copied to get the initial content </td>
193 <td><code>text</code></td>
194 <td> Initial text for the topic </td>
198 <td><code>topicparent</code></td>
199 <td> The parent topic </td>
203 <td><code>formtemplate</code></td>
204 <td> Name of the form to instantiate in the topic. Overrides the form set in the <code>templatetopic</code> if defined. </td>
208 <td><code>contenttype</code></td>
209 <td> Optional parameter that defines the application type to write into the CGI header. Defaults to <code>text/html</code>. May be used to invoke alternative client applications </td>
213 <td><code>anyname</code></td>
214 <td> Any parameter can passed to the new topic; if the template topic contains <code>%URLPARAM{"anyname"}%</code>, it will be replaced by its value </td>
218 <td><code>breaklock</code></td>
219 <td> If set, any lease conflicts will be ignored, and the edit will proceed even if someone is already editing the topic. </td>
224 Form field values are passed in parameters named 'field' - for example, if I have a field `Status` the parameter name is `Status`.
226 1. The first sequence of ten or more `X` characters in the topic name will be converted on save to a number such that the resulting topic name is unique in the target web.
228 NOTE: most skins support the definition of `EDIT_SKIN`, which is used as the value of the `cover` parameter in `edit` URLs. This allows you to override the default edit skin on a web, topic or user basis.
230 ### <a name="=login="></a> `login`
232 Used for logging in when TWiki login is being used (e.g TemplateLoginManager).
234 <table border="1" cellpadding="0" cellspacing="0">
236 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
237 <th bgcolor="#99CCCC"><strong> Description </strong></th>
238 <th bgcolor="#99CCCC"><strong> Default </strong></th>
241 <td><code>origurl</code></td>
242 <td> URL that was being accessed when an access violation occurred. the login process will redirect to this URL if it is successful </td>
246 <td><code>username</code></td>
247 <td> username of user logging in </td>
251 <td><code>password</code></td>
252 <td> password of user logging in </td>
257 ### <a name="=logon="></a> `logon`
259 Used for logging in when Web Server authentication is being used (e.g. ApacheLoginManager). The script does nothing; it is purely a placeholder for triggering the login process. The webserver will be set up to require a valid user to access this script, thus triggering the webserver login process.
261 ### <a name="=manage="></a> `manage`
263 Performs a range of management functions.
265 <table border="1" cellpadding="0" cellspacing="0">
267 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
268 <th bgcolor="#99CCCC"><strong> Description </strong></th>
269 <th bgcolor="#99CCCC"><strong> Default </strong></th>
272 <td><code>action</code></td>
273 <td> One of <code>createweb</code>, <code>deleteUserAccount</code>, <code>editSettings</code> or <code>saveSettings</code></td>
278 #### <a name="=action=createweb="></a> `action=createweb`
280 <table border="1" cellpadding="0" cellspacing="0">
282 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
283 <th bgcolor="#99CCCC"><strong> Description </strong></th>
284 <th bgcolor="#99CCCC"><strong> Default </strong></th>
287 <td><code>newweb</code></td>
288 <td> Name of the new web </td>
292 <td><code>baseweb</code></td>
293 <td> Name of the web to copy to create the new web </td>
297 <td><code>webbgcolor</code></td>
298 <td> value for WEBBGCOLOR </td>
302 <td><code>sitemapwhat</code></td>
303 <td> Value for SITEMAPWHAT </td>
307 <td><code>sitemapuseto</code></td>
308 <td> Value for SITEMAPUSETO </td>
312 <td><code>nosearchall</code></td>
313 <td> Value for NOSEARCHALL </td>
318 #### <a name="=action=delete_UserAccount="></a> `action=deleteUserAccount`
320 Unregisters (removes) the currently logged-in user.
322 <table border="1" cellpadding="0" cellspacing="0">
324 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
325 <th bgcolor="#99CCCC"><strong> Description </strong></th>
326 <th bgcolor="#99CCCC"><strong> Default </strong></th>
329 <td><code>password</code></td>
330 <td> Users' password </td>
335 #### <a name="=action=editSettings="></a> `action=editSettings`
339 #### <a name="=action=bulkRegister="></a> `action=bulkRegister`
341 See [[BulkRegistration]].
343 <table border="1" cellpadding="0" cellspacing="0">
345 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
346 <th bgcolor="#99CCCC"><strong> Description </strong></th>
347 <th bgcolor="#99CCCC"><strong> Default </strong></th>
350 <td><code>OverwriteHomeTopics</code></td>
351 <td> Whether to overwrite existing home topics or not </td>
355 <td><code>EmailUsersWithDetails</code></td>
356 <td> Whether to mail registered users or not </td>
360 <td><code>LogTopic</code></td>
361 <td> Topic to save the log in </td>
362 <td> Same as topic name, with 'Result' appended. </td>
366 #### <a name="=action=saveSettings="></a> `action=saveSettings`
368 <table border="1" cellpadding="0" cellspacing="0">
370 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
371 <th bgcolor="#99CCCC"><strong> Description </strong></th>
372 <th bgcolor="#99CCCC"><strong> Default </strong></th>
375 <td><code>text</code></td>
376 <td> Text of the topic </td>
380 <td><code>originalrev</code></td>
381 <td> Revision that the edit started on </td>
382 <td> Most recent revision </td>
386 All other parameters may be interpreted as form fields, depending on the current form definition in the topic.
388 ### <a name="=oops="></a> `oops`
390 This script is mainly used for rendering pages containing error messages, though it is also used for some functional actions such as manage pages (move topic etc).
392 `oops` templates are used with the `oops` script to generate system messages. This is done to make internationalisation or other local customisations simple.
394 The `oops` script supports the following parameters:
396 <table border="1" cellpadding="0" cellspacing="0">
398 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
399 <th bgcolor="#99CCCC"><strong> Description </strong></th>
400 <th bgcolor="#99CCCC"><strong> Default </strong></th>
403 <td><code>template</code></td>
404 <td> Name of the template file to display </td>
408 <td><code>def</code></td>
409 <td> Optional, can be set to the name of a single definition within <code>template</code>. This definition will be instantiated in the <code>template</code> wherever <code>%INSTANTIATE%</code> is seen. This lets you use a single template file for many messages. For an example, see <code>oopsmanagebad.tmpl</code>. </td>
413 <td><code>paramN</code></td>
414 <td> Where N is an integer from 1 upwards. These values will be substituted into <code>template</code> for <code>%PARAM1%</code> etc. </td>
419 ### <a name="=passwd="></a> `passwd`
421 <table border="1" cellpadding="0" cellspacing="0">
423 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
424 <th bgcolor="#99CCCC"><strong> Description </strong></th>
425 <th bgcolor="#99CCCC"><strong> Default </strong></th>
428 <td><code>action</code></td>
429 <td> one of <code>changePassword</code> or <code>resetPassword</code></td>
434 Other parameters as described under `manage`, `action=changePassword`.
436 #### <a name="=action=changePassword="></a> `action=changePassword`
438 <table border="1" cellpadding="0" cellspacing="0">
440 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
441 <th bgcolor="#99CCCC"><strong> Description </strong></th>
442 <th bgcolor="#99CCCC"><strong> Default </strong></th>
445 <td><code>username</code></td>
450 <td><code>oldpassword</code></td>
451 <td> Existing password (plain text) </td>
455 <td><code>password</code></td>
456 <td> New password (plain text) </td>
460 <td><code>passwordA</code></td>
461 <td> New password confirmation (plain text) </td>
465 <td><code>TopicName</code></td>
471 ### <a name="=preview="></a> `preview`
473 This script is _deprecated_. Its functions are covered by the `save` script.
475 ### <a name="=rdiff="></a> `rdiff`
477 Renders the differences between version of a TWiki topic
479 <table border="1" cellpadding="0" cellspacing="0">
481 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
482 <th bgcolor="#99CCCC"><strong> Description </strong></th>
483 <th bgcolor="#99CCCC"><strong> Default </strong></th>
487 <td> the higher revision </td>
492 <td> the lower revision </td>
497 <td> the rendering style {sequential, sidebyside, raw, debug} </td>
498 <td> DIFFRENDERSTYLE, <code>sequential</code></td>
502 <td> {history, diff, last} history diff, version to version, last version to previous </td>
503 <td><code>diff</code></td>
507 <td> number of lines of context </td>
514 - add a \{word\} render style
516 ### <a name="=register="></a> `register`
518 <table border="1" cellpadding="0" cellspacing="0">
520 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
521 <th bgcolor="#99CCCC"><strong> Description </strong></th>
522 <th bgcolor="#99CCCC"><strong> Default </strong></th>
525 <td><code>action</code></td>
526 <td><code>register</code> or <code>verify</code> or <code>resetPassword</code> or <code>approve</code></td>
531 ### <a name="=rename="></a> `rename`
533 Used for renaming topics.
535 <table border="1" cellpadding="0" cellspacing="0">
537 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
538 <th bgcolor="#99CCCC"><strong> Description </strong></th>
539 <th bgcolor="#99CCCC"><strong> Default </strong></th>
542 <td><code>skin</code></td>
543 <td> skin(s) to use </td>
547 <td><code>newweb</code></td>
548 <td> new web name </td>
552 <td><code>newtopic</code></td>
553 <td> new topic name </td>
557 <td><code>breaklock</code></td>
562 <td><code>attachment</code></td>
567 <td><code>confirm</code></td>
568 <td> if defined, requires a second level of confirmation </td>
572 <td><code>currentwebonly</code></td>
573 <td> if defined, searches current web only for links to this topic </td>
577 <td><code>nonwikiword</code></td>
578 <td> if defined, a non-wikiword is acceptable for the new topic name </td>
583 ### <a name="=resetpasswd="></a> `resetpasswd`
585 Reset the password for a single or multiple users
587 <table border="1" cellpadding="0" cellspacing="0">
589 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
590 <th bgcolor="#99CCCC"><strong> Description </strong></th>
591 <th bgcolor="#99CCCC"><strong> Default </strong></th>
594 <td><code>LoginName</code></td>
595 <td><strong>list</strong> of usernames to reset </td>
596 <td> none - error if not set </td>
599 <td><code>Introduction</code></td>
600 <td> message to be sent alongside the reset, most often used to announce to the user that they have been given an account. </td>
605 This is used by [[BulkResetPassword]] and [[ResetPassword]]. Only users belonging to the [[TWikiAdminGroup]] can provide a list of [[LoginNames]], non-admins can only provide a single [[LoginName]].
607 [[BulkRegistration]] provides the means to create multiple accounts but it does not announce those accounts to the users who own them. [[BulkResetPassword]] is used to assign the passwords, the Introduction is used to explain why they are receiving the mail.
609 ### <a name="=rest="></a> `rest`
611 This REST ([Representational State Transfer](http://en.wikipedia.org/wiki/REST)) script can be invoked via http in a similar way as the view script (see **Invocation Examples**, below) to execute a function that is associated to a "subject" and a "verb" (see below). It'll print the result directly to the stream unless the `endPoint` parameter is specified, in which case the control is redirected to the given topic.
613 The `rest` script itself uses one parameter:
615 <table border="1" cellpadding="0" cellspacing="0">
617 <td><code>endPoint</code></td>
618 <td> Where to redirect the response once the request is served, in the form "Web.Topic" </td>
622 Any additional parameters are passed directly to the function (i.e: The function can get any other parameter using the CGI $query object)
624 #### <a name="Invocation Examples"></a> Invocation Examples
626 The `rest` script assumes that it will be called with URL in the form:
628 `http://my.host/bin/rest/<subject>/<verb>`
630 where `<subject>` must be the [[WikiWord]] name of one of the installed [[TWikiPlugins]], and the `<verb>` is the alias for the function registered using the `registerRESTHandler`. The `<subject>` and `<verb>` are then used to lookup and call the registered function.
632 Functions outside the Plugins also can be registered, but please consider the security implications of allowing URL access, as functions can sidestep TWiki Authentication & Authorisation settings.
634 `<subject>` and `<verb>` are checked for illegal characters exactly in the same way as the web and topic names.
636 As an example, the [[EmptyPlugin]] has registered a function to be used with the `rest` script under the subject **EmptyPlugin** and the verb **example**. Click below to see the `rest` script in action (run as [[TWikiGuest]]).
638 [Call the Plugin](http://www.dementia.org/twiki/rest/EmptyPlugin/example?debugenableplugin=EmptyPlugin)
640 You can also call the function from the command line, but this will be run as the [[TWikiAdminGroup]] (as it is assumed that shell access is secure) - eg:
642 ./rest EmptyPlugin.example
644 Note that for calls to Plugins, they must be enabled in `configure`.
646 ### <a name="=save="></a> `save`
648 The `save` script performs a range of save-related functions, as selected by the `action` parameter.
650 <table border="1" cellpadding="0" cellspacing="0">
652 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
653 <th bgcolor="#99CCCC"><strong> Description </strong></th>
654 <th bgcolor="#99CCCC"><strong> Default </strong></th>
657 <td><code>action_save=1</code></td>
658 <td><strong>default</strong>; save, return to view, dontnotify is OFF </td>
662 <td><code>action_quietsave=1</code></td>
663 <td> save, and return to view, <code>dontnotify</code> is ON </td>
667 <td><code>action_checkpoint</code></td>
668 <td> save and redirect to the edit script, <code>dontnotify</code> is ON </td>
672 <td><code>action_cancel</code></td>
673 <td> exit without save, return to view </td>
677 <td><code>action_preview</code></td>
678 <td> preview edited text </td>
682 <td><code>action_addform</code></td>
683 <td> Redirect to the "change form" page. </td>
687 <td><code>action_replaceform...</code></td>
688 <td> Redirect to the "change form" page. </td>
692 <td><code>action_delRev</code></td>
693 <td><strong>Administrators only</strong> delete the most recent revision of the topic - all other parameters are ignored. You have to be a member of [[Main/TWikiAdminGroup]] to use this, and not all store implementations will support it. </td>
697 <td><code>action_repRev</code></td>
698 <td><strong>Administrators only</strong> replace the text of the most recent revision of the topic with the text in the <code>text</code> parameter. <code>text</code> must included embedded meta-data tags. All other parameters are ignored. You have to be a member of [[Main/TWikiAdminGroup]] to use this, and not all store implementations will support it. </td>
702 <td><code>onlynewtopic</code></td>
703 <td> If set, error if topic already exists </td>
707 <td><code>onlywikiname</code></td>
708 <td> If set, error if topic name is not a [[Main/WikiWord]]</td>
712 <td><code>dontnotify</code></td>
713 <td> if defined, suppress change notification </td>
717 <td><code>templatetopic</code></td>
718 <td> Name of a topic to use as a template for the text and form </td>
722 <td><code>text</code></td>
723 <td> New text of the topic </td>
727 <td><code>forcenewrevision</code></td>
728 <td> if set, forces a revision even if TWiki thinks one isn't needed </td>
732 <td><code>topicparent</code></td>
733 <td> If 'none' remove any current topic parent. If the name of a topic, set the topic parent to this. </td>
737 <td><code>formtemplate</code></td>
738 <td> if defined, use the named template for the form </td>
742 <td><code>editaction</code></td>
743 <td> When action is <code>checkpoint</code>, <code>add form</code> or <code>replace form...</code>, this is used as the <code>action</code> parameter to the <code>edit</code> script that is redirected to after the save is complete. </td>
747 <td><code>originalrev</code></td>
748 <td> Revision on which the edit started. </td>
753 Any errors will cause a redirect to an `oops` page.
755 The parameters are interpreted in according to the following rules.
757 1. The first sequence of ten or more `X` characters in the topic name will be converted to a number such that the resulting topic name is unique in the target web.
758 2. When the action is `save`, `checkpoint`, `quietsave`, or `preview`:
759 1. The new text is taken from the `text` parameter, if it is defined,
760 - otherwise it is taken from the `templatetopic`, if it is defined,
761 - otherwise it is taken from the previous version of the topic, if any,
762 2. The name of the new form is taken from the `formtemplate`, if defined
763 - otherwise it is taken from the `templatetopic`, if defined,
764 - otherwise it is taken from the previous version of the topic, if any,
765 - otherwise no form is attached.
766 3. The value for each field in the form is taken from the query, if it is defined
767 - otherwise it is taken from the `templatetopic`, if defined,
768 - otherwise it is taken from the previous version of the topic, if any,
769 - otherwise it defaults to the empty string.
771 Merging is only enabled if the topic text comes from `text` and `originalrev` is > 0 and is not the same as the revision number of the most recent revision. If merging is enabled both the topic and the meta-data are merged.
773 Form field values are passed in parameters named 'field' - for example, if I have a field `Status` the parameter name is `Status`.
775 ### <a name="=search="></a> `search`
777 CGI gateway to the `%SEARCH%` functionality driven by the following CGI parameters:
779 <table border="1" cellpadding="0" cellspacing="0">
781 <th bgcolor="#99CCCC"><strong> Parameter: </strong></th>
782 <th bgcolor="#99CCCC"><strong> Description: </strong></th>
783 <th bgcolor="#99CCCC"><strong> Default: </strong></th>
786 <td><code>"text"</code></td>
787 <td> Search term. Is a keyword search, literal search or regular expression search, depending on the <code>type</code> parameter. [[Main/SearchHelp]] has more </td>
791 <td><code>search="text"</code></td>
792 <td> (Alternative to above) </td>
796 <td><code>web="Name"</code><br /><code>web="Main, Know"</code><br /><code>web="all"</code></td>
797 <td> Comma-separated list of webs to search. See [[Main/TWikiVariables#VarSEARCH]] for more details. </td>
798 <td> Current web </td>
801 <td><code>topic="WebPreferences"</code><br /><code>topic="*Bug"</code></td>
802 <td> Limit search to topics: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. </td>
803 <td> All topics in a web </td>
806 <td><code>excludetopic="Web*"</code><br /><code>excludetopic="WebHome, WebChanges"</code></td>
807 <td> Exclude topics from search: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. </td>
811 <td><code>type="keyword"</code><br /><code>type="literal"</code><br /><code>type="regex"</code></td>
812 <td> Do a keyword search like <code>soap "web service" -shampoo</code>; a literal search like <code>web service</code>; or [[Main/RegularExpression]] search like <code>soap;web service;!shampoo</code></td>
813 <td><code>%SEARCHVAR- DEFAULTTYPE%</code> [[Main/TWikiPreferences]] setting (%SEARCHVARDEFAULTTYPE%) </td>
816 <td><code>scope="topic"</code><br /><code>scope="text"</code><br /><code>scope="all"</code></td>
817 <td> Search topic name (title); the text (body) of topic; or all (both) </td>
818 <td><code>"text"</code></td>
821 <td><code>order="topic"</code><br /><code>order="created"</code><br /><code>order="modified"</code><br /><code>order="editby"</code><br /><code>order=<br /> "formfield(name)"</code></td>
822 <td> Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of [[Main/TWikiForms]]. The sorting is done web by web; in case you want to sort across webs, create a [[Main/FormattedSearch]] table and sort it with [[Main/TablePlugin]]'s initsort </td>
823 <td> Sort by topic name </td>
826 <td><code>limit="all"</code><br /><code>limit="16"</code></td>
827 <td> Limit the number of results returned. This is done after sorting if <code>order</code> is specified </td>
828 <td> All results </td>
831 <td><code>date="..."</code></td>
832 <td> limits the results to those pages with latest edit time in the given [[Main/TimeInterval]]. </td>
833 <td> All results </td>
836 <td><code>reverse="on"</code></td>
837 <td> Reverse the direction of the search </td>
838 <td> Ascending search </td>
841 <td><code>casesensitive="on"</code></td>
842 <td> Case sensitive search </td>
843 <td> Ignore case </td>
846 <td><code>bookview="on"</code></td>
847 <td>[[Main/BookView]] search, e.g. show complete topic text </td>
848 <td> Show topic summary </td>
851 <td><code>nonoise="on"</code></td>
852 <td> Shorthand for <code>nosummary="on" nosearch="on" nototal="on" zeroresults="off" noheader="on" noempty="on"</code></td>
856 <td><code>nosummary="on"</code></td>
857 <td> Show topic title only </td>
858 <td> Show topic summary </td>
861 <td><code>nosearch="on"</code></td>
862 <td> Suppress search string </td>
863 <td> Show search string </td>
866 <td><code>noheader="on"</code></td>
867 <td> Suppress search header <br /><span style="background: #FFB0B0"> <strong>Topics: Changed: By:</strong> </span></td>
868 <td> Show search header </td>
871 <td><code>nototal="on"</code></td>
872 <td> Do not show number of topics found </td>
873 <td> Show number </td>
876 <td><code>zeroresults="off"</code></td>
877 <td> Suppress all output if there are no hits </td>
878 <td><code>zeroresults="on"</code>, displays: "Number of topics: 0" </td>
881 <td><code>noempty="on"</code></td>
882 <td> Suppress results for webs that have no hits. </td>
883 <td> Show webs with no hits </td>
886 <td><code>header="..."</code><br /><code>format="..."</code></td>
887 <td> Custom format results: see <strong>[[Main/FormattedSearch]]</strong> for usage, variables & examples </td>
888 <td> Results in table </td>
891 <td><code>expandvariables="on"</code></td>
892 <td> Expand variables before applying a [[Main/FormattedSearch]] on a search hit. Useful to show the expanded text, e.g. to show the result of a [[Main/SpreadSheetPlugin]] <code>%CALC{}%</code> instead of the formula </td>
896 <td><code>multiple="on"</code></td>
897 <td> Multiple hits per topic. Each hit can be [[Main/FormattedSearch]]. The last token is used in case of a regular expression ";" <em>and</em> search </td>
898 <td> Only one hit per topic </td>
901 <td><code>nofinalnewline="on"</code></td>
902 <td> If <code>on</code>, the search variable does not end in a line by itself. Any text continuing immediately after the search tag on the same line will be rendered as part of the table generated by the search, if appropriate. </td>
903 <td><code>off</code></td>
906 <td><code>separator=", "</code></td>
907 <td> Line separator between hits </td>
908 <td> Newline <code>"$n"</code></td>
912 ### <a name="=statistics="></a> `statistics`
914 Refresh the [[WebStatistics]] topics in range of webs.
916 <table border="1" cellpadding="0" cellspacing="0">
918 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
919 <th bgcolor="#99CCCC"><strong> Description </strong></th>
920 <th bgcolor="#99CCCC"><strong> Default </strong></th>
923 <td><code>webs</code></td>
924 <td><strong>list</strong> of webs to run stats on </td>
929 ### <a name="=twiki="></a> `twiki`
931 Single-script interface to the functionality of all the other scripts. Experimental, not for production use. Read the code if you want to know more.
933 ### <a name="=upload="></a> `upload`
935 Uploads an attachment to a topic. The HTTP request is expected to be in `multipart/form-data` format.
937 <table border="1" cellpadding="0" cellspacing="0">
939 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
940 <th bgcolor="#99CCCC"><strong> Description </strong></th>
941 <th bgcolor="#99CCCC"><strong> Default </strong></th>
944 <td><code>hidefile</code></td>
945 <td> if defined, will not show file in attachment table </td>
949 <td><code>filepath</code></td>
950 <td> local (client) path name of the file being uploaded. This is used to look up the data for the file in the HTTP query. </td>
954 <td><code>filename</code></td>
955 <td> deprecated, do not use </td>
959 <td><code>filecomment</code></td>
960 <td> Comment to associate with file in attachment table </td>
964 <td><code>createlink</code></td>
965 <td> if defined, will create a link to file at end of topic </td>
969 <td><code>changeproperties</code></td>
970 <td> if defined, this is a property change operation <strong>only</strong> - no file will be uploaded. </td>
975 You can use a tool like `curl` to upload files from the command line using this script.
977 ### <a name="=view="></a> `view`
979 Used for viewing topics.
981 <table border="1" cellpadding="0" cellspacing="0">
983 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
984 <th bgcolor="#99CCCC"><strong> Description </strong></th>
985 <th bgcolor="#99CCCC"><strong> Default </strong></th>
988 <td><code>raw=on</code></td>
989 <td> Shows the text of the topic in a scrollable textarea </td>
993 <td><code>raw=debug</code></td>
994 <td> As <code>raw=on</code>, but also shows the metadata (forms etc) associated with the topic. </td>
998 <td><code>raw=text</code></td>
999 <td> Shows only the source of the topic, as plain text (Content-type: text/plain). Only shows the body text, <strong>not</strong> the form or other meta-data. </td>
1002 <td><code>raw=all</code></td>
1003 <td> Shows only the source of the topic, as plain text (Content-type: text/plain), <strong>with embedded meta-data</strong>. This may be useful if you want to extract the source of a topic to a local file on disc. </td>
1007 <td><code>contenttype</code></td>
1008 <td> Allows you to specify a different <strong>Content-Type:</strong> (e.g. <code>contenttype=text/plain</code>) </td>
1012 <td><code>rev</code></td>
1013 <td> Revision to view (e.g. <code>rev=45</code>) </td>
1017 <td><code>template</code></td>
1018 <td> Allows you to specify a different skin template, overriding the 'view' template the view script would normally use. The default template is <code>view</code>. For example, you could specify [[%WEB%/%TOPIC%?template=edit]]. This is mainly useful when you have specialised templates for a TWiki Application. </td>
1023 %X% For historical reasons, the view script has a special interpretation of the `text` skin. In earlier TWiki versions the `skin=text` parameter was used like this: `http://.../view/MyWeb/MyTopic?skin=text&contenttype=text/plain&raw=on` which shows the topic as plain text; useful for those who want to download plain text for the topic. Using `skin=text` this way is **DEPRECATED**, use `raw=text` instead.
1025 ### <a name="=viewfile="></a> `viewfile`
1027 Used for viewing attachments. Normally, a site will publish the attachments (`pub`) directory using a URL. However if it contains sensitive information, you will want to protect attachments using [[TWikiAccessControls]]. In this case, you can use the `viewfile` script to give access to attachments while still checking access controls.
1029 <table border="1" cellpadding="0" cellspacing="0">
1031 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
1032 <th bgcolor="#99CCCC"><strong> Description </strong></th>
1033 <th bgcolor="#99CCCC"><strong> Default </strong></th>
1036 <td><code>filename</code></td>
1037 <td> name of attachment </td>
1041 <td><code>rev</code></td>
1042 <td> Revision to view </td>
1047 ## <a name="Command Line Scripts"></a> Command Line Scripts
1049 Details on command line scripts located in the `twiki/tools` directory.
1051 ### <a name="=geturl.pl="></a> `geturl.pl`
1053 This is a very simple script to get the content of a web site. It is marked as _deprecated_ and might be removed (or enhanced) in a future TWiki release. Its functions are covered by the standard `wget` and `curl` commands.
1055 - Usage: `geturl <host> <path> [<port> [<header>]]`
1056 - Example: `geturl some.domain /some/dir/file.html 80`
1057 - Will get: `http://some.domain:80/some/dir/file.html`
1059 ### <a name="=rewriteshebang.pl="></a> `rewriteshebang.pl`
1061 Simple script to rewrite the `#!/usr/bin/perl` shebang lines specific to your local Perl installation. It will rewrite the first line of all your TWiki cgi scripts so they use a different shebang line. Use it if your perl is in a non-standard location, or you want to use a different interpreter (such as 'speedy').
1063 ### <a name="=tick_twiki.pl="></a> `tick_twiki.pl`
1065 This script executes a number of non-essential regular administration tasks that will help keep your TWiki healthy and happy, such as removing expired sessions and lease files.
1067 It is intended to be run as a cron job or a scheduled task once a week. Example crontab entry:%BR% `0 0 * * 0 cd /usr/twiki/bin && perl ../tools/tick_twiki.pl`
1069 **_Note:_** The script has to be run by a user who can write files created by the webserver user.
1071 **_Related Topics:_** [[AdminDocumentationCategory]], [[DeveloperDocumentationCategory]]