source: trunk/core/data/System/CommandAndCGIScripts.txt @ 14627

Revision 14627, 40.1 KB checked in by SvenDowideit, 13 months ago (diff)

Item11746: small spelling fix

  • Property svn:keywords set to Revision Date
Line 
1%META:TOPICINFO{author="ProjectContributor" date="1316607717" format="1.1" version="1"}%
2%META:TOPICPARENT{name="DeveloperDocumentationCategory"}%
3%STARTINCLUDE%
4---+ CGI and Command Line Scripts
5
6_Programs on the server performing actions such as rendering, saving and renaming topics._
7
8These scripts are located in the =bin= and =tools= directories. This topic describes the interfaces to some of those scripts. All scripts in the =bin= directory can be called from the CGI ([[http://en.wikipedia.org/wiki/Common_Gateway_Interface][Common Gateway Interface]]) environment or from the command line. The scripts in the =tools= directory can only be called from the command line.
9
10%TOC%
11
12---++ CGI Scripts
13Details on CGI scripts located in the =bin= directory.
14
15Note that a blank in the 'Default' column means that the parameter
16is not required, and has no default. _required_ means the
17parameter is required, and has no default. text _in italics_ describes
18default behaviour if no value is given.
19
20---+++ General Information
21---++++ CGI environment
22In 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 user is used (usually =guest=).
23---++++ Command-line
24You *must* be have the =bin= directory on the perl path 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=.
25
26Parameters are passed on the command line using '-name' - for example,
27<verbatim class="bash">
28$ cd /usr/local/foswiki/bin
29$ save -topic MyWeb.MyTopic -user admin -action save -text "New text of the topic"
30</verbatim>
31All parameters require a value, even if that is the empty string. Note that parameters passed on the command-line should *not* be URL-encoded.
32
33When calling a =tools= script from the command line, you normally need to be cd'd to the =bin directory e.g.
34<verbatim class="bash">
35$ cd bin
36$ ../tools/mailnotify -q -nonews -nochanges -Main -System
37</verbatim>
38
39---++++ Common parameters
40All 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:
41
42| *Parameter* | *Description* | *Default* |
43| =cover= | Specifies temporary skin path to prepend to the skin path for this script only (see [[Skins]]) | |
44| =debugenableplugins= | During debugging it can be useful to selectively disable all but a subset of plugins. This parameter allows the caller to specify a comma-separated list of plugins that should be enabled. | |
45| =foswikioriginalquery= | The original query that was being made before a redirect for user confirmation was required. | |
46| =foswiki_redirect_cache= | Foswiki sometimes caches long lists of parameters that must survive over a sequence of browser redirects. This parameter identifies one of these caches. The parameter value is a "magic number" that uniquely idenitifies a file in the =working/tmp= directory. These files have a very short lifetime, and are destroyed when the cache is read. | |
47| =logout= | requests the !LoginManager to log the current user out (this happens at the begining of the request so will terminate any other operation requested) | |
48| =refresh= | If the Foswiki page cache is in use, setting this parameter will invalidate the cache. Valid values are =on= and =all=. See PageCaching for more information on the page cache. | |
49| =response= | Used as part of the request validation process. | |
50| =skin= | Overrides the default skin path (see [[Skins]]) | _value of the =SKIN= preference_ |
51| =t= | While the =t= parameter is not actively used by any scripts, it is used when building links to scripts such as =edit=, to ensure that each edit link is unique. This stops the browser from trying to use a cached reply from a previous call to the script. | _generally set to current time, in seconds_ |
52| =topic= | Overrides the web.topic path given in the URL (specify Web.<nop>TopicName) | |
53| =user= | 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. | |
54| =validation_key= | part of cross-site scripting protection. Any request sent from browsers that might change data stored on the server must carry a key that indentifies the source of the request. | |
55| _&lt;any name&gt;_ | Any other parameter name passed to the script is passed through for possible use by the script.  This is _typically_ only applicable to the =edit=, =save= and =view= scripts. | |
56
57Where revision parameters are required, individual versions are identified by positive, non-zero integers. Versions start with 1 and are sequencial. For compatibility reasons, Some scripts accept revision numbers with '1.' (or even 'r1.') prepended to the number, but this usage is deprecated and should be corrected when encountered.
58
59---+++ =attach=
60Despite 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.
61
62| *Parameter* | *Description* | *Default* |
63| =filename= | Name of existing attachment (if provided, this is a "manage attachment" action) | _this is a "new attachment" action_ |
64
65---+++ =changes=
66Shows all the changes in the given web.
67
68The =changes= script can receive one parameter:
69
70| *Parameter* | *Description* | *Default* |
71| =minor= | If 0, show only major changes. If 1, show all the changes (both minor and major) | _show major changes_ |
72
73The main difference between invoking this script and using WebChanges is that WebChanges is based on a =%<nop>SEARCH%=, while this script reads the =changes= file in each web, making it much faster.
74
75*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.
76
77---+++ =configure=
78=configure= is the browser script used for inspection of, and changes to, the site configuration. None of the parameters to this script are useable for any purpose except =configure=. See [[%SCRIPTURLPATH{"configure"}%][configure]].
79
80---+++ =edit=
81The =edit= script understands the following parameters, typically supplied by HTML input fields.
82
83A major role of the =edit= script is new topic creation. Parameters that are mainly relevant to new topic creation are marked with %ICON{"wip"}%
84
85| *Parameter name* | *Description* | *Default* |
86| =action= | If =action=text=, then hide the form. If =action=form=, then hide the normal text area and only edit the form. | _edit both_ |
87| =breaklock= | If set, any lease conflicts will be ignored, and the edit will proceed even if someone is already editing the topic. | |
88| =contenttype= | Optional parameter that defines the application type to write into the CGI header. May be used to invoke alternative client applications | =text/html= |
89| =formtemplate= | Name of the form to instantiate in the topic. Set to =none= to remove any existing form. | |
90| =notemplateexpansion= | %ICON{"wip"}% Do not expand any macros in the template topic.  (see [[#NewTopicCreation][New topic creation]] below) | _expand_ |
91| =onlynewtopic= | %ICON{"wip"}% If =on=, error if the topic already exists | _edit existing topic_ |
92| =onlywikiname= | %ICON{"wip"}% If =on=, error if the name of a topic being created is not a WikiWord | _allow non-wikiword names_ |
93| =redirectto= | If the user continues from edit to save, and if the save (or cancel) process is successful, save will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | |
94| =rev= | Lets you specify a specific revision to use as the basis of the edit. | _latest_ |
95| =template= | Allows you to specify a different skin template. Overrides any setting of =[[SkinTemplates#TemplatePreferences][EDIT_TEMPLATE]]=. | |
96| =templatetopic= | %ICON{"wip"}% The name of the template topic, copied to get the initial content for a new topic. (see [[#NewTopicCreation][New topic creation]] below) | |
97| =text= | %ICON{"wip"}% Set the text to be edited. If this parameter is not given, the text is taken from the existing topic (if it exists) | |
98| =topicparent= | Sets the parent topic. | |
99| _&lt;any name&gt;_ | This can be used in two ways; first, if the topic has a form with a field called _&lt;any name&gt;_, it will set the value of that field. %ICON{"wip"}% Second, it can be expanded in the topic text during topic creation - see [[#NewTopicCreation][New topic creation]] below | |
100
101__Skin notes:__
102
103The =[[SkinTemplates#TemplatePreferences][EDIT_TEMPLATE]]= preference (or the =template= parameter) can be used to override the default 'edit' template on a per-web or per-topic basis.
104
105The =action= parameter works by loading the =editform.tmpl= or =edittext.tmpl= templates in place of the standard =edit.tmpl=. If an =EDIT_TEMPLATE= has been defined, then it replaces =edit=, e.g. if =EDIT_TEMPLATE=specialed= and =action=form= then the template used will be =specialedform=
106
107In most skins that are based on the default templates (such as Pattern skin) you can easily change the =Edit= and =Edit Wiki<nop>Text= buttons to append the =action= parameter, by setting the [[PreferenceSettings][preference]] [[VarEDITACTION][EDITACTION]] to the value =text= or =form=. (You can always get back to editing the whole topic by removing the =action= parameter from the URL browser Location window, and reloading the edit window).
108
109#NewTopicCreation
110__New topic creation %ICON{"wip"}%:__
111
112The string AUTOINC followed by one or more digits anywhere in the topic name will be converted to a number such that the resulting topic name is unique in the target web. However this doesn't happen until the topic is saved.
113
114When a new topic is created using edit, the topic isn't actually created until the edit is saved. The content of the new topic is initialised according to the parameters you pass.
115   * =templatetopic= - defines the full name (web.topic) of a topic to use as a template for the new topic. The template topic is copied and, unless =notemplateexpansion= is set, the following macros are expanded in the topic text: =URLPARAM=, =DATE=, =SERVERTIME=, =GMTIME=, =USERNAME=, =WIKINAME=, =WIKIUSERNAME=, =USERINFO=. (see %SYSTEMWEB%.TopicTemplates)
116   * =text= - use this as the text of the topic. Macros are *not* expanded in this text. Overrides any text set in the =templatetopic=.
117   * =formtemplate= - Overrides any form set in the =templatetopic=.
118   * =notemplateexpansion= - given by =templatetopic=. Use this when you want a verbatim copy of a topic.
119   * =onlynewtopic= and =onlywikiname= are used to control validation of the new topic name.
120   * _&lt;any name&gt;_ - besides the form field value setting described above, when creating a new topic, =%<nop>URLPARAM{"= _&lt;any name&gt;_ ="}%= in the =templatetopic= will be expanded to the parameter value.
121
122---+++ =login=
123Used for logging in with !TemplateLoginManager, and for interactive validation of operations that require user confirmation.
124| *Parameter* | *Description* | *Default* |
125| =foswikiloginaction= | If 'validate', the login script is being used for interactive validation of an operation. Otherwise it is being used for login. | |
126| =foswiki_origin= | URL that was being accessed when an access violation occurred. the login process will redirect to this URL if it is successful | |
127| =remember= | If set, this will cause the user's login to be retained even after their browser is shut down. |
128| =sudo= | promote login to internal wiki admin (admins only) | |
129| =password= | password of user logging in | |
130| =username= | username of user logging in (if set, login will attempt to authenticate) | |
131| =usernamestep= | used to initialise the =username= input field in the login form (will not attempt to authenticate) | |
132
133---+++ =logon=
134Used 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 must be set up to require a valid user to access this script, thus triggering the webserver login process.
135 
136---+++ =manage=
137Performs a range of management functions.
138
139<blockquote class="foswikiHelp"> *%X% Note:* The =manage= script can only be called via the HTTP POST method. Make sure you specify =method="post"= if you call the =manage= script via a form action. It is not possible to call =manage= from an =&lt;a href ...&gt;= link.</blockquote>
140
141| *Parameter* | *Description* | *Default* |
142| =action= | One of =create=, =createweb=, =changePassword=, =resetPassword=, =bulkRegister=, =deleteUserAccount=, =editSettings=, =saveSettings=, =restoreRevision= | _required_ |
143
144---++++ =action=create=
145Alternative entry point for creation, via =edit=, of a new topic, used by screens that support several actions using =manage=.
146| *Parameter* | *Description* | *Default* |
147| =topic= | Name of topic to create (can be web.topic) | _required_ |
148Other parameters are the same as for =edit=.
149
150---++++ =action=createweb=
151Create a new web
152| *Parameter* | *Description* | *Default* |
153| =baseweb= | Name of the web to copy to create the new web | _required_ |
154| =newtopic= | Value of %<nop>TOPIC% within the web creation message. Optionally used in some skins to signify a non-default home topic. | |
155| =newweb= | Name of the new web | _required_ |
156| =nosearchall= | Value for NOSEARCHALL | '' |
157| =webbgcolor= | value for WEBBGCOLOR | '' |
158| =websummary= | Value for WEBSUMMARY | '' |
159
160---++++ =action=editSettings=
161No parameters
162
163---++++ =action=saveSettings=
164| *Parameter* | *Description* | *Default* |
165| =originalrev= | Revision that the edit started on | _latest_ |
166| =redirectto= | If the savesettings process is successful, save will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | _redirect to the web.topic from the URL path_ |
167| =text= | Text of the topic | _required_ |
168| =action_save= | Must be set to =Save= or settings are not saved | _required_ |
169| =action_cancel= | Must be set to =Cancel= to cancel save. | _required_ |
170If neither =action_save= or =action_cancel= are provided, an oops error is issued. All other parameters may be interpreted as form fields, depending on the current form definition in the topic.
171
172---++++ =action=bulkRegister=
173See BulkRegistration.
174| *Parameter* | *Description* | *Default* |
175| =logtopic= | Topic to save the log in | _same as topic name, with 'Result' appended_ |
176| =overwritehometopics= | Whether to overwrite existing home topics or not | _do not overwrite_ |
177
178---++++ =action=changePassword=
179Change password, email address, or both, of a user.
180| *Parameter* | *Description* | *Default* |
181| =email= | new email address | |
182| =oldpassword= | current password | _required, unless current user is an admin_ |
183| =password= | new password | |
184| =passwordA= | new password confirmation | _required if =password= is given_ |
185| =username= | login name of user to change password/email for | _required_ |
186=password, =passwordA= and =email= are optional. If neither or =password= and =passwordA= is set, then the user password is left unchanged. If =email= is unset, their email is left unchanged.
187
188---++++ =action=resetPassword=
189Reset the password for a single or multiple users
190| *Parameter* | *Description* | *Default* |
191| =introduction= | message to be sent alongside the reset, most often used to announce to the user that they have been given an account.  | |
192| =loginname= | *list* of usernames to reset | _required_ |
193
194This is used by BulkResetPassword and ResetPassword. Only administrators can provide a list of LoginNames, non-admins can only provide a single LoginName.
195
196BulkRegistration 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.
197
198---++++ =action=deleteUserAccount=
199Unregisters (removes) the currently logged-in user.
200| *Parameter* | *Description* | *Default* |
201| =password= | Users' password | _required_ |
202
203---++++ =action=restoreRevision=
204Alternative entry point for =edit=, used by screens that support several actions using =manage. Parameters are as for =edit=.
205
206---++++ =action=addUserToGroup=
207add a user / list of users to a group
208| *Parameter* | *Description* | *Default* |
209| =create= | create the group if it doesn't exist | =0= |
210| =groupname= |groupname to change | _required_ |
211| =redirectto= | If the add process is successful, =manage= will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | None.  An Oops screen showing the results is returned. |
212| =username= | *list* of usernames/wikinames to add to group | _required_ |
213
214---++++ =action=removeUserFromGroup=
215remove a user / list of users to a group
216| *Parameter* | *Description* | *Default* |
217| =groupname= |groupname to change | _required_ |
218| =redirectto= | If the remove process is successful, =manage= will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | None.  An Oops screen showing the results is returned. |
219| =username= | *list* of usernames/wikinames to add to group | _required_ |
220
221---+++ =oops=
222This 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).
223
224=oops= templates are used with the =oops= script to generate system messages. This is done to make internationalisation or other local customisations simple.
225
226The =oops= script supports the following parameters:
227
228| *Parameter* | *Description* | *Default* |
229| =def= | Can be set to the name of a single definition within =template=. This definition will be instantiated in the =template= wherever =%<nop>INSTANTIATE%= is seen. This lets you use a single template file for many messages. For an example, see =oopsmanagebad.tmpl=. | |
230| =paramN= | Where N is an integer from 1 upwards. These values will be substituted into =template= for =%<nop>PARAM1%= etc. | |
231| =template= | Name of the template file to display | =oops= |
232
233---+++ =preview=
234This script is _deprecated_. Its functions are covered by the =save= script.
235
236---+++ =rdiff=
237Renders the differences between version of a topic
238
239| *Parameter* | *Description* | *Default* |
240| =context= | number of lines of context | |
241| =render= | the rendering style {sequential, sidebyside, raw, debug} | =DIFFRENDERSTYLE=, =sequential= |
242| =rev1= | the higher revision | _latest_ |
243| =rev2= | the lower revision | _latest_ |
244| =type= | =history= gives a history, =diff= rev1 against rev2, =last= latest to previous | =diff= |
245The =context= parameter is only respected if the back-end store supports
246context diffs.
247
248---+++ =register=
249
250| *Parameter* | *Description* | *Default* |
251| =action= | =register= or =verify= or =approve= | _required_ |
252
253<blockquote class="foswikiHelp"> *%X% Note:* The =register= script can only be called via the HTTP POST method except when the action is =verify=. Make sure you specify =method="post"= if you call the =register= script via a form action. It is not possible to call =register= from an =&lt;a href ...&gt;= link. The =verify= action is an exception as it is used to verify registration by clicking a href link from an email.</blockquote>
254
255| *Parameter* | *Description* | *Default* |
256| =addtogroups= | Accepts a comma-separated list of group names to add the user to. | |
257| =code= | (verify= only) Activation code, verifies a pending registration  |
258| =create= | If =on=, and a group being added to does not exist, create it. | |
259| =email= | New user's email address | _required_ |
260| =firstname= | New user's first name | _required_ |
261| =lastname= | New user's surname | _required_ |
262| =loginname= | New user's login name | _required_ |
263| =password= | New user's password | |
264| =wikiname= | Wikiname of user being registered | _required_ |
265| &lt;any name&gt; | Any other parameter passed during registration will normally be passed on into the new user's home topic, or ignored. |
266
267---+++ =rename=
268Used for renaming webs, topics and attachments.
269
270| *Parameter* | *Description* | *Default* |
271| =action= | =renameweb= or =renameother= | =renameother= |
272| =confirm= | if non-0, requires a second level of confirmation | |
273| =referring_topics= | (internal use only) list of topics that refer to the web or topic being renamed | |
274| =redirectto= | If the rename process is successful, rename will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | _the renamed topic_ |
275
276---++++ =action="renameweb"=
277Rename a web.
278| *Parameter* | *Description* | *Default* |
279| =newparentweb= | new parent web name | _existing parent_ |
280| =newsubweb= | new web name | |
281
282---++++ =action=renameother=
283Rename a topic or an attachment.
284| *Parameter* | *Description* | *Default* |
285| =attachment= | Attachment to move | |
286| =currentwebonly= | if non-0, searches current web only for links to this topic | _search all webs_ |
287| =newattachment= | New name for attachment | _same as =attachment=, if given_ |
288| =newtopic= | new topic name | _required_ |
289| =newweb= | new web name | _required_ |
290| =nonwikiword= | if =on=, a non-wikiword is acceptable for the new topic name | =off= |
291| =template= | template for error when an attachment doesn't exist, =deleteattachment= for when deleting an attachment | |
292
293<blockquote class="foswikiHelp"> *%X% Note:* The =rename= script can only be called via the HTTP POST method. Make sure you specify =method="post"= if you call the =rename= script via a form action. It is not possible to call =rename= from an =&lt;a href ...&gt;= link.</blockquote>
294
295---+++ =resetpasswd=
296This script is _deprecated_. Its functions are covered by the =manage= script.
297
298---+++ =rest=
299This REST ([[http://en.wikipedia.org/wiki/REST][Representational State Transfer]]) script can be invoked via http in the same way as the other scripts (see *Invocation Examples*, below) to execute a function that is associated to a "subject" and a "verb" (see below). These functions are usually registered by plugins using the =Foswiki::Func::registerRESTHandler= method. The =rest= script will print the result directly to the browser unless the =endPoint= parameter is specified, in which case it will output a redirect to the given topic.
300
301The =rest= script supports the following parameters:
302| *Parameter* | *Description* | *Default* |
303| =endPoint= | Where to redirect the response once the request is served, in the form "Web.Topic". If not given, the REST script must generate a valid response. | |
304| =password= | See =username= | |
305| =username= | If =TemplateLogin=, or a similar login manager not embedded in the web server, is used, then you can pass a username and password to the server (though see below for a preferred way to pass authentication information). |
306
307REST scripts that require a topic context must use the standard =topic= parameter to pass the topic name, as the URL path is used to identify the REST function. If not defined, then the topic context in REST handlers will be [[%USERSWEB%.%HOMETOPIC%]].
308
309The function is free to use any other query parameters for its own purposes.
310
311---++++ =rest= authentication
312If a REST operation requires a logged-in user but no user is logged in, then it will return a 401 status. In the case of the =TemplateLogin= login manager, this will include a =WWW-Authenticate= header starting with =FoswikiBasic=. This allows the status to percolate through to Javascript where it can be handled by your code. The =realm= in the =WWW-Authenticate= header is taken from the ={AuthRealm}= setting in =configure=, or the empty string if it is not set.
313
314If you are using =TemplateLogin=, the preferred way to pass user login information back to the server is to use the =X-Authorization= HTTP header. This header is modelled on the HTTP Authorization header, as described in [[http://www.ietf.org/rfc/rfc2617.txt]], except that the scheme name =FoswikiBasic= is used instead of =Basic=. The user-id and password are combined with a : and base64 encoded. For example, if the user agent wishes to send the userid "Aladdin" and password "open sesame", it would use the following header field:
315<verbatim>
316X-Authorization: FoswikiBasic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
317</verbatim>
318When used with jQuery:
319<verbatim>
320$.ajax({
321  beforeSend: function(xhrObj){
322    xhrObj.setRequestHeader("X-Authorization",
323      "FoswikiBasic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
324  }
325});
326</verbatim>
327
328<blockquote class="foswikiHelp"> %X% The =rest= script should *always* be configured to require authentication in any site that is using =ApacheLogin=. Otherwise there is a risk of opening up major security holes. So make sure you add it to the ={AuthScripts}= list in =configure=.</blockquote>
329
330---++++ Invocation Examples
331
332The =rest= script assumes that it will be called with URL in the form:
333
334=http://my.host/bin/rest/&lt;subject&gt;/&lt;verb&gt;=
335
336where =&lt;subject&gt;= must be the WikiWord name of one of the installed [[Plugins]], and the =&lt;verb&gt;= is the alias for the function registered using the =Foswiki::Func::registerRESTHandler= method. The =&lt;subject&gt;= and =&lt;verb&gt;= are then used to lookup and call the registered function.
337
338=&lt;subject&gt;= and =&lt;verb&gt;= are checked for illegal characters exactly in the same way as the web and topic names.
339
340As an example, the EmptyPlugin has registered a function to be used with the =rest= script under the subject *EmptyPlugin* and the verb *example*.
341
342The URL to call this function from a browser would be:
343   * =%SCRIPTURL{rest}%/EmptyPlugin/example?debugenableplugins=EmptyPlugin=
344alternatively, to run it from the commandline:
345   * =cd foswiki/bin ; ./rest /EmptyPlugin/example debugenableplugins=EmptyPlugin=
346
347Note that for Plugins to register REST handlers, they must be enabled in =configure=.
348
349---++++ Retrieving passed values
350Additional parameters can be recovered via the query object in the =$session=, for example with the url:
351<verbatim class="html">
352http://my.host/bin/rest/MyPlugin/update?web=foo
353</verbatim>
354
355The url parameters can be processed using:
356<verbatim class="perl">
357my $query = $session->{request};
358my $web = $query->{param}->{web}[0];
359</verbatim>
360
361---+++ =save=
362The =save= script performs a range of save-related functions.
363
364| *Parameter* | *Description* | *Default* |
365| =action_addform= | Redirect _to_ the "change form" page. | |
366| =action_cancel= | exit without save, return to view | |
367| =action_checkpoint= | save and redirect to the edit script, =dontnotify= is =on= | |
368| =action_delRev= | *Administrators only* delete the most recent revision of the topic - all other parameters are ignored. You have to be an administrator to use this, and not all store implementations will support it. | |
369| =action_preview= | preview edited text | |
370| =action_quietsave= | save, and return to view, =dontnotify= is =on= | |
371| =action_replaceform= | Redirect _from_ the "change form" page. | |
372| =action_repRev= | *Administrators only* replace the text of the most recent revision of the topic with the text in the =text= parameter. =text= must included embedded meta-data tags. All other parameters are ignored. You have to be an administrator to use this, and not all store implementations will support it. | |
373| =action_save= | *default behaviour*; save, return to view | |
374| =dontnotify= | if non-0, suppress change notification | |
375| =edit= | The bin script to use to re-edit the topic when action is =checkpoint= | =edit= |
376| =editaction= | When action is =checkpoint=, =add form= or =replace form...=, this is used as the =action= parameter to the =edit= script that is redirected to after the save is complete. | |
377| =editparams= | The parameter string to use to edit the topic when action is =checkpoint= | |
378| =forcenewrevision= | if set, forces a revision even if %WIKITOOLNAME% thinks one isn't needed | |
379| =formtemplate= | if defined, use the named template for the form (will remove the form if set to 'none') | |
380| =newtopic= | If =templatetopic= is given, and this parameter is set to 1 and the topic does not exist, will clear the initial topic text. | |
381| =onlynewtopic= | If set, error if topic already exists | |
382| =onlywikiname= | If set, error if topic name is not a WikiWord | |
383| =originalrev= | Revision on which the edit started. | |
384| =redirectto= | The save process will redirect to this topic or URL if it is successful. (Typically this would be the URL that was being viewed when edit was invoked). The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | _topic specified in URL path_ |
385| =template= | The template to use to re-edit the topic when action is =checkpoint= | |
386| =templatetopic= | Name of a topic to use as a template for the text and form (new topic _only_) (see [[#NewTopicCreation][New topic creation]] above) | |
387| =text= | New text of the topic | |
388| =topicparent= | If 'none' remove any current topic parent. If the name of a topic, set the topic parent to this. | |
389| _&lt;any name&gt;_ | If the topic has a form with a field called _&lt;any name&gt;_, it will set the value of that field. | |
390
391Any errors will cause a redirect to another page, either an =oops= page to report the error, or a =login= if the save is not authorized.
392
393The string AUTOINC followed by one or more digits anywhere in the topic name will be converted to a number such that the resulting topic name is unique in the target web.
394
395When the action is =save=, =checkpoint=, =quietsave=, or =preview=:
396   1 The new text is taken from the =text= parameter, if it is defined,
397      * otherwise it is taken from the =templatetopic=, if it is defined, (new topic _only_)
398      * otherwise it is taken from the previous version of the topic, if any,
399   1 The name of the new form is taken from the =formtemplate=, if defined
400      * otherwise it is taken from the =templatetopic=, if defined, (new topic _only_)
401      * otherwise it is taken from the previous version of the topic, if any,
402      * otherwise no form is attached.
403   1 The value for each field in the form is taken from the query, if it is defined
404      * otherwise it is taken from the =templatetopic=, if defined, (new topic _only_)
405      * otherwise it is taken from the previous version of the topic, if any,
406      * otherwise it defaults to the empty string.
407
408Merging is only enabled if the topic text comes from =text= and =originalrev= is &gt; 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.
409
410Form field values are passed in parameters named 'field' - for example, if I have a field =Status= the parameter name is =Status=.
411
412<blockquote class="foswikiHelp"> *%X% Note:* The =save= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =save= script via a form action. Example:
413<verbatim class="html">
414<form name="new" action="%SCRIPTURLPATH{save}%/Sandbox/" method="post">
415    ...
416</form>
417</verbatim>
418It is not possible to call =save= from an =&lt;a href ...&gt;= link.</blockquote>
419
420---+++ =search=
421This cgi script has been deprecated. When called, it will redirect to the WebSearch topic, and the parameters will be passed on.
422
423---+++ =statistics=
424<!--
425   * Set ISSTATISTICSTOPIC = %IF{"istopic '%STATISTICSTOPIC%'" else="!WebStatistics" then="[[$percntSTATISTICSTOPIC$percnt][WebStatistics]]"}%
426-->
427Refresh the %ISSTATISTICSTOPIC% topics in range of webs.
428| *Parameter* | *Description* | *Default* |
429| =logdate= | YYYYMM to generate statistics for | _current month_ |
430| =webs= | comma-separated list of webs to run stats on | _all accessible webs_ |
431
432for example:
433   1 from browser %SCRIPTURL{"statistics"}% updates _all user webs_
434   2 from browser %SCRIPTURL{"statistics"}%?webs=Userweb,%SANDBOXWEB% updates _Userweb,%SANDBOXWEB%_
435   3 from browser %SCRIPTURL{"statistics"}%/%WEB%/ updates %WEB%
436   4 from command line bin/statistics updates _all user webs_
437   5 from command line bin/statistics -webs=Userweb,%SANDBOXWEB% updates _Userweb,%SANDBOXWEB%_
438   6 from command line bin/statistics %WEB%.<nop>WebHome updates %WEB%
439
440see SiteTools#WebStatistics for more details on %ISSTATISTICSTOPIC% and how to update statistics using cron.
441
442---+++ =upload=
443Uploads an attachment to a topic. The HTTP request is expected to be in =multipart/form-data= format.
444| *Parameter* | *Description* | *Default* |
445| =changeproperties= | if non=0, this is a property change operation *only* - no file will be uploaded. | |
446| =createlink= | if non-0, will create a link to file at end of topic | |
447| =filecomment= | Comment to associate with file in attachment table | |
448| =filepath= | local (client) path name of the file being uploaded. This is used to look up the data for the file in the HTTP query. | |
449| =hidefile= | if non-0, will not show file in attachment table | |
450| =noredirect= | Normally the script will redirect to 'view' when the upload is \
451     complete, but also designed to be useable for REST-style calling using \
452     the 'noredirect' parameter. If this parameter is set it will return an \
453     appropriate HTTP status code and print a message to STDOUT, starting \
454     with 'OK' on success and 'ERROR' on failure. | |
455| =redirectto= | URL to redirect to after upload. The parameter value can be a \
456     =TopicName=, a =Web.TopicName=, or a URL. Redirect to a URL only works \
457     if it is enabled in =configure=, and is ignored if =noredirect= is \
458     specified.%BR% (Miscellaneous ={AllowRedirectUrl}=). | _topic specified in URL path_ |
459
460*Tips*
461   * You can use a tool like =curl= to upload files from the command line using this script.
462   * You can call upload easily from !XmlHttpRequest in Javascript.
463
464<blockquote class="foswikiHelp"> *%X% Note:* The =upload= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =upload= script via a form action. It is not possible to call =upload= from an =&lt;a href ...&gt;= link.</blockquote>
465
466---+++ =view=
467Used for viewing topics.
468
469| *Parameter* | *Description* | *Default* |
470| =contenttype= | Allows you to specify a different *Content-Type:* (e.g. =contenttype=text/plain=) | =text/html= |
471| =raw= | <ul>\
472<li> =on= - show the text of the topic in a scrollable textarea. </li> \
473<li> =debug= - as =on=, but also shows the metadata (forms etc) associated with the topic. </li> \
474<li> =text= - show only the source of the topic, as plain text (Content-type: text/plain). Only shows the body text, *not* the form or other meta-data. </li> \
475<li> =all= - show only the source of the topic, as plain text (Content-type: text/plain), *with embedded meta-data*. This may be useful if you want to extract the source of a topic to a local file on disc. </li></ul> | |
476| =rev= | Revision to view (e.g. =rev=45=) | _latest_ |
477| =SEARCH&lt;hex number&gt;= | Identifies a result set that is being paged through | |
478| =section= | Allows to view only a part of the topic delimited by a named section (see %SYSTEMWEB%.VarSTARTSECTION). If the given section is not present, no topic content is displayed. | |
479| =template= | Allows you to specify a different skin template, overriding the 'view' template the view script would normally use. The default template is =view=. For example, you could specify [[%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit][%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit]]. This is mainly useful when you have specialised templates for a Wiki Application. | |
480| _&lt;any name&gt;_ | It can be expanded in the topic text during rendering and referenced in IF statements  - See the %SYSTEMWEB%.VarURLPARAM macro and %SYSTEMWEB%.IfStatements | |
481
482<blockquote class="foswikiHelp"> %X% For historical reasons, the view script has a special interpretation of the =text= skin. This skin cannot be redefined.</blockquote>
483
484---+++ =viewfile=
485Used 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 [[AccessControl][AccessControls]]. In this case, you can use the =viewfile= script to give access to attachments while still checking access controls.
486
487| *Parameter* | *Description* | *Default* |
488| =filename= | name of attachment | _required_ |
489| =rev= | Revision to view | _latest_ |
490
491Instead of using the =filename= parameter, you can append the attachment name
492to the end of the URL path (after the topic) e.g. =%SCRIPTURL{viewfile}%/Webname/TopicName/Attachment.gif=
493
494---++ Tool Scripts
495Details on command line scripts located in the =tools= directory.
496
497---+++ =geturl.pl=
498This is a very simple script to get the content of a web site, either using GET or POST. It is marked as _deprecated_ and might be removed in a future release. Its functions are covered by the standard =wget= and =curl= commands, which have the added advantage of performing authentication..
499   * Usage:    =geturl.pl &lt;host&gt; &lt;path&gt; [&lt;port&gt; [&lt;header&gt;]]=
500   * Example:  =geturl.pl some.domain /some/dir/file.html 80=
501   * Will get: =http://some.domain:80/some/dir/file.html=
502   * Example:  =geturl.pl POST some.domain /bin/statistics?webs=Sandbox=
503   * Will post: =http://some.domain/bin/statistics?webs=Sandbox= triggering a statistics run
504
505---+++ =rewriteshebang.pl=
506Simple script to rewrite the =#!/usr/bin/perl= [[http://en.wikipedia.org/wiki/Shebang_%28Unix%29][shebang]] lines specific to your local Perl installation. It will rewrite the first line of all your 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').
507
508---+++ =tick_foswiki.pl=
509This script executes a number of non-essential regular administration tasks that will help keep your site healthy and happy, such as removing expired sessions and lease files.
510
511It is intended to be run as a cron job or a scheduled task once a week. Example crontab entry:%BR%
512=0 0 * * 0 cd /usr/local/foswiki/bin && perl ../tools/tick_foswiki.pl=
513
514*Note:* The script has to be run by a user who can write files created by the webserver user.
515
516Extensions, such as the MailerContrib, also install tool scripts. Check the documentation of the extension for details.
517
518---+++ =extension_installer=
519This script will download and install, or remove an extension.
520
521For more details, execute it from the Foswiki root directory with the =usage= parameter:
522<verbatim>
523./tools/extension_installer usage
524</verbatim>
525Note that this script is a generic version of the =_installer= script shipped with each extension.  There are 3 ways to install a script using these scripts:
526   * Download =SomePlugin_installer= and execute it from the Foswiki root directory
527   * run =./tools/extension_installer !SomePlugin= - the extension will be downloaded and installed
528   * Use the configure web interface to the Extensions Installer.
529
530---+++ =dependencies_installer.pl=
531This script searches for missing Perl modules that should be available according to your Foswiki environment and offers installation via CPANPLUS or a supported package management system. It eases Perl module installation, which is part of a Foswiki installation, may be part of an extension installation or may need to follow upgrades. The script can be used to just provide an overview of Foswiki related perl modules in your installation by running it with option =-v=.
532
533For more details, execute it using option -h (help) or -m (manual):
534<verbatim>
535./dependencies_installer.pl -h
536Usage:
537    dependencies_installer.pl [-h|?|--help] [-m|--man] [-p|--print]
538    [-q|--questions] [-v|--verbose]
539
540[...]
541</verbatim>
542
543---
544*Related Topics:* AdminDocumentationCategory, DeveloperDocumentationCategory
545<!-- %JQREQUIRE{"chili"}% -->
Note: See TracBrowser for help on using the repository browser.