I am trying to implement an automatic submission to an information management system from within my Symfony2 application. Someone else has written a perl script for the submission. I just need to use the controller to get values from an entity to pass to the script as arguments.
I have tested the perl script by running a short php script from the command line:
<?php
$perlscript = 'test_submit_to_lims.pl';
$output = \shell_exec('perl ' . $perlscript . " 'arg1' 'arg2' 'arg3' ");
echo $output;
?>
This returns a string with some values of interest which I need for my application.
I have put the perl script and dependent files in a folder called dependencies at the same level as my Symfony project folder
I tried to use similar code in my controller:
...
$arg1 = $form->get('arg1')->getData();
$arg2 = $form->get('arg2')->getData();
$arg3 = $form->get('arg3')->getData();
$pathToScript = '/opt/sfprojects/dependencies';
$perlScript = "$pathToScript/test_submit_to_lims.pl";
$output = \shell_exec('perl '.$perlScript." $arg1 $arg2 $arg3 ");
var_dump($output);
...
This gives me "Network Error: 500 Internal Server Error - http://www2-mywebsite.org/myEntity/create"
I'm not sure whether the error is caused by something simple in my php code, by the need to somehow enable perl in a Symfony configuration file or something else like the location of the script, file permissions, etc.
I would appreciate any ideas of where I may have gone wrong.