Question
I want to create a simple perl script (myscript) which would in turn call two scripts (save and sendemail). This is required for me to have a single submit button on my topic which will allow the users to post a comment and also send a mail with a single click (instead of having to click once to post a comment and then click again to send a mail).
I created myscript with these contents:
#!c:/cygwin/bin/perl -wT
require "/twiki/bin/sendemail";
require "/twiki/bin/save";
exit;
The problem is that it executes just the sendmail script. If I interchange the second and third lines, then it executes just the save script.
I tried using the commands
#!c:/cygwin/bin/perl -w
system ("/usr/bin/perl -wT /twiki/bin/sendemail");
system ("/usr/bin/perl -wT /twiki/bin/save");
exit;
instead of 'require' but with the same results.
Can you please help me write myscript ?
Environment
--
ChengappaCB - 29 Jan 2008
Answer
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.
I solved it this way:
- Save the script 'sendemail' under the name 'saveandsendemail'
- Copy the following lines from the 'save' script to the 'saveandsendemail' script.
use TWiki::UI::Save;
TWiki::UI::run( \&TWiki::UI::Save::save, save => 1 );
- Call the 'saveandsendemail' script to do the job.
The last lines of my 'saveandsendemail' script are:
use TWiki;
use TWiki::UI;
use TWiki::Plugins::SendEmailPlugin;
use TWiki::UI::Save;
my $query = new CGI;
$TWiki::Plugins::SESSION = new TWiki(undef, $query);
TWiki::UI::run( \&TWiki::Plugins::SendEmailPlugin::sendEmail );
TWiki::UI::run( \&TWiki::UI::Save::save, save => 1 );
--
ChengappaCB - 15 Feb 2008
Quite useful, thanks for sharing this with the TWiki community!
--
PeterThoeny - 23 Jan 2009