PerlSamplePlugin
Execute and format nicely some Perl code embedded in a TWiki page, showing STDOUT and STDERR outputs
Introduction
This plugin executes and nicely formats a piece of Perl code, together with its STDOUT and STDERR outputs. To avoid improper usage it executes the Perl code in a
CPAN:Safe
compartment.
Syntax Rules
Enclose Perl code in
%PERLSAMPLE{ and
}%.
Usage Example
| You type: | You get: | If correctly installed: |
%PERLSAMPLE{
print "hello world!";
}%
|
| |
code |
return |
1 |
print "hello world!"; |
1 |
|
stdout |
stderr |
|
1: hello world! |
|
|
%PERLSAMPLE{print "hello world!";}%
|
To-Do
- Apply a timeout to the perl execution (spawn a delayed kill process)
- Limit the output size (disk quota?)
- Use a random generated file for the output/stderr
Plugin Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%PERLSAMPLEPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Execute and format nicely some Perl code embedded in a TWiki page, showing STDOUT and STDERR outputs
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
- Install the CPAN:Safe
Perl module (see http://www.cpan.org
)
- Make sure that
bin/perl_stdout.tmp and bin/perl_stderr.tmp are writable by the Apache user
- Download the ZIP file from the Plugin Home (see below)
- Unzip
PerlSamplePlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/PerlSamplePlugin.txt | Plugin topic |
lib/TWiki/Plugins/PerlSamplePlugin.pm | Plugin Perl module |
- Configure the plugin:
- Run the configure script to enable the plugin
- Test if the installation was successful:
Plugin Info
Related Topics: TWikiPlugins,
DeveloperDocumentationCategory,
AdminDocumentationCategory,
TWikiPreferences