Hi,
I have a CGI task where I am using a perl script to invoke another dotnet console application. I am using backticks to execute the EXE. The perl script alone is working; but when I try to invoke it from workflow, the script does not wait for the output and continues next line execution. Please find my script below:
#!G:\Interwoven\TeamSite/iw-perl/bin/iwperl
use TeamSite::CGI_lite;
use TeamSite::WFtask;
use TeamSite::WFworkflow;
use TeamSite::WFsystem;
use XML::Writer;
use IO::File;
use XML::XPath;
use XML::XPath::XMLParser;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new TeamSite::CGI_lite;
$cgi->parse_data();
my($taskid) = $cgi->{form}{iw_taskid} || $cgi->{form}{task_id};
my($iwmount) = TeamSite::Config::iwgetmount();
my($task) = TeamSite::WFtask->new($taskid);
my(
@taskfiles) = $task->GetFiles();
my($wfs) =$task->GetArea();
my $work_area=$iwmount.$wfs;
my $tempOutPutfilename="G:/WFProcessor/input.xml";
my $output = new IO::File(">".$tempOutPutfilename);
my $writer = new XML::Writer(OUTPUT => $output);
$writer->startTag("root");
$writer->startTag("files","workarea"=>"$work_area","FileType"=> "XML");
foreach my $file (
@taskfiles){
$fullpath=$work_area."/".$file;
if (-f $fullpath){
$writer->startTag("file","type"=>"file","status"=>"0"); }
elsif (-d $fullpath){
$writer->startTag("file","type"=>"folder","status"=>"0"); }
$writer->characters($file);
$writer->endTag("file");
}
$writer->endTag("files");
$writer->endTag("root");
$writer->end();
my
@out;
@out = `G:/WFProcessor/CaptureMetadataConsole.exe G:/WFProcessor/input.xml`;
sleep(20);
print "Content-type: text/html\n\n";
my $str = join('',
@out);
if($str eq "Success\n")
{
$task->CallBack(1,"Fail");
}
else
{
$task->CallBack(0,"Success");
}
Before I get a proper result on
@out, the next line executes and always calls the Success link.
Please tell me how we can make this perl script wait for the exe execution to finish.