2
votes

I am trying to invoke swi-prolog from within a php script like :

exec("start plwin.exe -f C:\\path\\load.pl -g run_from_file.", $os1);
print_r($os1);

I can see that prolog window gets opened and complies the file, but immediately exits displaying an exit status as 1. I am sure that it is not executing the predicate I want to to execute.

Is there any other to invoke prolog with appropriate parameters and keep the window open without automatically exiting?

UPDATE : I configured the system env variables to the path where prolog is installed.

2
is run_from_file really supposed to have a dot at the end of it?Variable Length Coder
I assumed since we normally use dot to terminate statement in prolog?JPro
I'm assuming you're using php CLI? Have you tried adding the third exec parameter to capture the exit status? Howabout not executing the start command to run in a new window but instead just do plwin.exe? Also, to wait for user input from within the php script, thereby holding the window open so you have time to see all output, use fgets(STDIN);bob-the-destroyer
To add, I mentioned running plwin.exe in same window only because fgets(STDIN); is applied to the original window your CLI script is running in, not to the second window spawned by the start command, which already came and went.bob-the-destroyer

2 Answers

0
votes

This link seems to have some helpful information about different ways that this can be done.

http://www.j-paine.org/dobbs/prolog_from_php.html

0
votes

I have also used the tutorial from http://www.j-paine.org/dobbs/prolog_from_php.html , and it was giving me a blank screen. To run prolog file on a server where swipl is used, I changed to:

$cmd = swipl -f /path/to/myfile.pl -g test,halt -t 'halt(1)';

I found all needed information here: http://www.swi-prolog.org/pldoc/man?section=cmdline , in section 2.4.4

The rest of the php file is the same as in the example, and now it really executes test from myfile.pl.

Maybe his can help somebody.