Running external program on Scrip Action

Hi!
I’m trying to do some pdf parsing by invoking “pdftotext” from an action:

my ($rh, $wh);
my $pid = open2( $rh, $wh ,"pdftotext - -" ); 
print $wh decode_base64($attachment);          
$wh->close();
while (<$rh>) {
    # process
}
$rh->close();

This code works when invoked directly from a shell, but fails to produce any output when invoked as a Scrip Action.
Could this be related to apache? Or the way rt runs actions? Any clue?

Thanks!

My first guess would be where is that file being written to, maybe Apache doesn’t have Linux rights to create a file in that directory?

The first attempt used temporary files, so that is what I thought as well.

This second version of the code does not create any file, it uses instead $rh and $wh streams to feed input and collect the output.

What output are you expecting? You can try adding some logging statements using RT::Logger->error();

1 Like

Ok, by using open3 and RT::Logger I saw errors on stderr.
This was due to the fact that the attachment was already decoded from base64, after removing decode_base64() everything works.

Thanks