Page 1 of 1

Launching an executable

PostPosted: Fri Jan 20, 2012 4:23 am
by camt
My company has a license generator executable, my idea was for parameters to be entered, then when the data is submit, it also fires off this program and passes it those parameters.

Can this be done?

I know that php has the exec() and other functions, and a CGI script can be run from apache. Have written php scripts to launch an executable on their own and tried a few things but cannot get them to run from an action in Xataface.

Any help on whether this could be done would be greatly appreciated.

Cheers,
Cam

Re: Launching an executable

PostPosted: Mon Jan 23, 2012 7:42 am
by amrcode1
Hi, I setup something like that, my case is this:
User need a report (some operations) so, we have a easy-table with fields like parameters.
User Save this record (request) of report.
In Delegate Class (Mytable.php) i use the aftersave function of Xataface, collect the fields (parameter) and use function exec() and pass all parameters.
Code is like this:

Code: Select all
<?
class Table{

   function afterSave(&$record){
      $qed = $record->val('id');
      $proj = $record->val('project');
      $date1 = $record->val('date1');
      $date2 = $record->val('date2');
      $sp=" ";
      exec("/usr/bin/R --vanilla --args ".$qed.$sp.$proj.$sp.$date1.$sp.$date2." < r/aed.R");
}
?>


This Call the Statistical program R, pass all the args, R run all the code in the aed.R, and insert all the results in the same record with $qued, in this case, i don't have control of execution (time) of R, this procedure take in the max case 10 minutes, i hope this can help you.

Re: Launching an executable

PostPosted: Mon Jan 23, 2012 12:31 pm
by shannah
As the above response exemplifies this certainly can be done. If you are having trouble running exec from a Xataface action, check the error log to see what the problem is. Some servers put restrictions on the use of functions like exec, so you might have to tinker with the settings to get everything working...

-Steve

Re: Launching an executable

PostPosted: Wed Jan 25, 2012 7:03 am
by camt
Thanks very much!
Am currently testing on a windows machine but will let you know how it goes.

Regards,

Cam

Re: Launching an executable

PostPosted: Fri Feb 24, 2012 3:19 am
by camt
Thank you - this works great on our linux server, for Windows it was much more difficult to set up.