|
TWiki CGI and Command Line Scripts |
|
|
|
> > | |
| CGI Scripts
Details on CGI scripts located in the twiki/bin directory. |
|
> > | |
| General Information |
|
> > | |
| CGI environment
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 ). |
|
> > | |
| Command-line
You must have the twiki/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 . |
| Parameters are passed on the command line using '-name' - for example,
$ cd /usr/local/twiki/bin |
|
< < | $ save -topic MyTopic -user admin -action save -text "New text of the topic" |
> > | $ save -topic MyTopic -user admin -method POST -action save -text "New text of the topic" |
|
All parameters require a value, even if that is the empty string. |
|
> > | |
| Common parameters
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:
Parameter |
Description |
Default |
topic |
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) |
|
|
|
< < |
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 authorized users should be allowed to execute scripts from the command line. |
|
|
> > |
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 authorized users should be allowed to execute scripts from the command line. |
TWikiAdminGroup |
method |
Commad-line only; set the HTTP request method. Some scripts requires the POST method under certain circumstances. In such a case, you need to specify the POST method to run the script from a command line. |
GET |
|
|
skin |
Overrides the default skin path (see TWikiSkins) |
|
cover |
Specifies temporary skin path to prepend to the skin path for this script only (see TWikiSkins) |
|
|
|
> > | |
| attach
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. |
|
Parameter |
Description |
Default |
filename |
Name of existing attachment (if provided, this is a "manage attachment" action) |
none (in which case this is a "new attachment" action) |
|
|
> > | |
| changes
Shows all the changes in the given web. |
|
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. |
|
> > | |
| configure
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 . See configure. |
|
> > | |
| edit
The edit script understands the following parameters, typically supplied by HTML input fields: |
|
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. |
|
> > | |
| login
Used for logging in when TWiki login is being used (e.g TemplateLoginManager). |
|
username |
username of user logging in |
none |
password |
password of user logging in |
none |
|
|
> > | |
| logon
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.
|
|
> > | |
| manage
Performs a range of management functions. |
|
Note: The manage script can only be called via http POST method for createweb renameweb , and deleteUserAccount . |
|
> > | |
| action=createweb
|
|
sitemapwhat |
Value for SITEMAPWHAT |
'' |
nosearchall |
Value for NOSEARCHALL |
'' |
|
|
> > | |
| action=renameweb
|
|
newparentweb |
New parent web name |
'' |
confirm |
If defined, requires a second level of confirmation. Supported values are "getlock", "continue", and "cancel" |
'' |
|
|
> > | |
| action=editSettings
No parameters |
|
> > | |
| action=saveSettings
|
|
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. Note: Redirect to a URL only works if it is enabled in configure (Security setup > Miscellaneous {AllowRedirectUrl} ). |
All other parameters may be interpreted as form fields, depending on the current form definition in the topic. |
|
> > | |
| action=bulkRegister
See BulkRegistration. |
|
EmailUsersWithDetails |
Whether to mail registered users or not |
false |
LogTopic |
Topic to save the log in |
Same as topic name, with 'Result' appended. |
|
|
> > | |
| action=changePassword
Change password, email address, or both, of a user. |
|
email |
new email address |
none |
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. |
|
> > | |
| action=resetPassword
Reset the password for a single or multiple users |
|
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. |
|
> > | |
| action=deleteUserAccount
Unregisters (removes) the currently logged-in user.
|
|
> > | |
| oops
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). |
|
def |
Optional, can be set to the name of a single definition within template . This definition will be instantiated in the template wherever %INSTANTIATE% is seen. This lets you use a single template file for many messages. For an example, see oopsmanagebad.tmpl . |
|
paramN |
Where N is an integer from 1 upwards. These values will be substituted into template for %PARAM1% etc. |
|
|
|
> > | |
| preview
This script is deprecated. Its functions are covered by the save script. |
|
> > | |
| rdiff
Renders the differences between version of a TWiki topic |
| TODO:
- add a {word} render style
|
|
> > | |
| register
|
|
Note: The register script can only be called via http POST method, not GET. Make sure to specify the "post" method if you call the register script via a form action. |
|
> > | |
| rename
Used for renaming topics and attachments. |
|
Note: The rename script can only be called via http POST method, not GET. Make sure you specify method="post" if you call the rename script via a form action. |
|
> > | |
| copy
Used for copying the current topic in its entirety including its history and attachments. |
|
overwrite |
By default, copy does not happen if the destination topic already exists. If this parameter is 'on' , the destination topic is deleted if exists before copying takes place |
off (no overwrite) |
disablefixlinks |
Bypass fixing WikiWord links in the copy destination topic if copy is done across webs. Fixing links in the copied topic such as from SomeLink to Otherweb.SomeLink is usually desirable so that links in the copied topic still point to the same target |
off (links are fixed) |
|
|
> > | |
| mdrepo
Used to retrieve and update data in MetadataRepository.
Please read MetadataRepository#mdrepo_script_from_command_line and MetadataRepository#mdrepo_script_from_browser. |
|
> > | |
| rest
This REST (Representational State Transfer ) script can be invoked via http in the same way as the other TWiki 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 TWiki::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. |
|
Note that for Plugins to register REST handlers, they must be enabled in configure . |
|
> > | |
| save
The save script performs a range of save-related functions, as selected by the action parameter. |
|
It is not possible to call save from an <a href=""> link. |
|
> > | |
| search
CGI gateway to the %SEARCH% functionality driven by the following CGI parameters: |
|
Parameter: |
Description: |
Default: |
"text" |
Search term. Is a keyword search, literal search or regular expression search, depending on the type parameter. SearchHelp has more |
required |
search="text" |
(Alternative to above) |
N/A |
|
|
< < |
web="Name" web="Main, Know" web="all" |
Comma-separated list of webs to search. See TWikiVariables#VarSEARCH for more details. |
Current web |
|
> > |
web="Name" web="Main, Know" web="all" |
Comma-separated list of webs to search. See VarSEARCH for more details. |
Current web |
|
|
topic="WebPreferences" topic="*Bug" |
Limit search to topics: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. |
All topics in a web |
excludetopic="Web*" excludetopic="WebHome, WebChanges" |
Exclude topics from search: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. |
None |
type="keyword" type="literal" type="regex" |
Do a keyword search like soap "web service" -shampoo ; a literal search like web service ; or RegularExpression search like soap;web service;!shampoo |
%SEARCHVAR- DEFAULTTYPE% preferences setting (literal) |
|
|
nofinalnewline="on" |
If on , 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. |
off |
separator=", " |
Line separator between hits |
Newline "$n" |
|
|
> > | |
| statistics
Refresh the WebStatistics topics in range of webs. |
|
See TWikiSiteTools#WebStatistics_site_statistics for updating statistics using cron. |
|
> > | |
| upload
Uploads an attachment to a topic. The HTTP request is expected to be in multipart/form-data format.
|
|
< < |
hidefile |
if defined, will not show file in attachment table |
|
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. |
|
filename |
deprecated, do not use |
|
|
> > |
hidefile |
If defined, will not show file in attachment table |
|
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. |
|
filename |
Deprecated, do not use |
|
|
|
filecomment |
Comment to associate with file in attachment table |
|
|
|
< < |
createlink |
if defined, will create a link to file at end of topic |
|
changeproperties |
if defined, this is a property change operation only - no file will be uploaded. |
null |
updatefield |
If defined and if the value matches the name of a form field, it will update that form field with the name of the uploaded file. |
|
|
> > |
createlink |
If defined, will create a link to file at end of topic |
|
changeproperties |
If defined, this is a property change operation only - no file will be uploaded. |
null |
updatefield |
If defined and if the value matches the name of a form field, it will update that form field with the format defined by the updateformat parameter. |
|
updateformat |
Format of the value of the form field indicated by the updatefield parameter. The default is the name of the attached file, but can be set to include more, such as the path to the image, %PUBURL%/%BASEWEB%/%BASETOPIC%/$filename . |
$filename |
|
|
You can use a tool like curl to upload files from the command line using this script.
Note: The upload script can only be called via http POST method, not GET. |
|
> > | |
| view
Used for viewing topics. |
| 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. |
|
> > | |
| viewfile
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. |
|
|
|
> > |
debug |
Put debug info to the debug log |
|
|
|
Instead of using the filename parameter, you can append the attachment name
to the end of the URL path (after the topic) e.g. https://cds.kuhep.kreonet.net/wiki/twiki-6.1.0/bin/viewfile/Webname/TopicName/Attachment.gif |
|
> > | In that case, determining the attachment file name is non-trivial -- please consider a file name having multiple dots and a file name having no dots.
As such, the process of determining the file name is put on the debug log if debug=1 URL parameter is supplied. |
| |
|
> > | |
| Command Line Scripts
Details on command line scripts located in the twiki/tools directory. |
|
> > | |
| geturl.pl
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. |
|
- Example:
geturl.pl some.domain /some/dir/file.html 80
- Will get:
http://some.domain:80/some/dir/file.html
|
|
> > | |
| rewriteshebang.pl
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'). |
|
> > | |
| tick_twiki.pl |
|
> > | |
| 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.
It is intended to be run as a cron job or a scheduled task once a week. Example crontab entry: |