Tags:
create new tag
view all tags

SID-00207: Can I update a twiki string with a perl script

Status: Answered Answered TWiki version: Perl version:
Category: CategoryAutomation Server OS: Last update: 10 years ago

In a page, I have "Build Number: 123456 March 19, 2009"

I would like to update the build number and timestamp "123456 March 19, 2009" via an outside script (immediately after a build is successful) (NOTE that the Twiki host is NOT the same one I'll be triggering the script from)

Is this possible?

If so, where do I look?

thanks in advance

suu

-- SuuQuan - 19 Mar 2009

Discussion and Answer

The easiest way to update TWiki content from outside is to update a TWikiForms field via URL parameter.

Let's abuse the form field called "Web server" on this page. You can issue an http get request to the save script of this page, appending a "Webserver" parameter with a value of choice.

Test using YYYY-MM-DD-HH-MM-SS format. Click on this link and watch the "Web server" form field at the bottom:
https://www.twiki.org/cgi-bin/save/Support/SID-00207?Webserver=2026-01-28-08-00-01;forcenewrevision=on

The forcenewrevision parameter forces a new page revision each time you access the URL. You can call this URL from an external script. See also TWikiScripts

-- PeterThoeny - 20 Mar 2009

Thanks Peter. I shall test this on my sandbox.

-- SuuQuan - 24 Mar 2009

I am having a little trouble (mis)understanding the instructions at TWikiForms. Which Perl module/function can I use to simulate the click on the URL to activate cgi?

-- SuuQuan - 25 Mar 2009

Your outside script needs to make the HTTP request, using something like wget or CURL.

-- SeanCMorgan - 25 Mar 2009

On TWiki, all you need is a page that has a TWiki form attached to it (like this page).

As Sean mentioned, your own script needs to issue an HTTP request to TWiki's save script (as per above example). There are tools/libraries to interact with websites via HTTP. For Perl see CurlTool, WwwMechanize, CPAN:LWP.

-- PeterThoeny - 25 Mar 2009

Thanks, I'll read those modules. But I am having a difficult time "attaching a form template" to my page. I followed the instructions, but instead of having the form displaying all the fields, I only have a rectanble button, with the name of the template as the label. When I read this page in EDIT mode, I do not see anything different inside the text portion that would suggest you manipulate that template.

-- SuuQuan - 25 Mar 2009

First you need to define a TWiki form, then attach it to a page. Please study TWikiForms.

-- PeterThoeny - 25 Mar 2009

know what? I used another form, that happens to have almost the same name as the form I wanted to use. It works now. Now all I have to do is to learn how to use WWW::Mechanize::TWiki to simulate that click

-- SuuQuan - 28 Mar 2009

I am glad it worked out for you. May be you can share how you did it so that other community members can learn?

-- PeterThoeny - 28 Mar 2009

See also related example SID-00250.

-- PeterThoeny - 2012-05-22

Above example no longer works because recent TWiki releases require an http POST to update content, e.g. http GET is no longer supported for security. An http POST can be done with an HTML form button, as with this example:

Source:

<form action="%SCRIPTURL{save}%/%WEB%/%TOPIC%" method="post">
<input type="hidden" name="Webserver" value="%GMTIME{$year-$mo-$day-$hou-$min-$sec}%" />
<input type="hidden" name="forcenewrevision" value="on" />
<input type="submit" value="Record timestamp" class="twikiButton" />
</form>

-- PeterThoeny - 2012-12-19

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Can I update a twiki string with a perl script
SupportCategory CategoryAutomation
TWiki version

Server OS

Web server 2015-08-17-19-59-15
Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r23 < r22 < r21 < r20 < r19 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r23 - 2015-08-17 - TWikiGuest
 
  • 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.