I am working with prolog and php. I am using php, to call prolog.
I am using swi-prolog Version 7.1.17 and XAMPP 1.7.7 [PHP: 5.3.8].My command :
$cmd ='swipl -q -f C:\Users\MyComp\Desktop\test.pl -g test,halt';
Here C:\Users\MyComp\Desktop\test.pl is prolog file directory. It is worked properly. but Now I update the XAMPP version(above 1.7.7) then it is not work. but the command it is work properly in cmd in windows.How can i solve this kind of problem? Any command will using All XAMPP version for call prolog from php.
You Try with
nice -n15 /software/bin/pl -f /home/popx/cgi-bin/test.pl -g test,halt
This may be work with your specification.
See the reference
Related
So I have installed MAMP and I am using PHP, however I also used Terminal with PHP as well. Now for some reason Terminal is not working with PHP anymore, for example:
Terminal / PHP command not found
So basically I can not work with anything at the moment. I have also simplified .bashrc and .bash_profile.
Terminal and PHP not found
Thanks. mac-machine
cd ~ && nano .zshrc
Add the path of php in .zshrc like:
export PATH=/Applications/MAMP/bin/php/php8.0.8/bin:$PATH
Then run source .zshrc and run php -v to confirm path setup
The problem is working with PHP command line is not found with ZSH, it gets a message: zsh: command not found: php.
So working with older BASH instead of ZSH it works fine.
In PHP running on Ubuntu, I can run exec('npm -v') and the output is good,
but I can't run exec('gitbook xxxx').
gitbook is a npm package I installed by
npm install gitbook -g
I can run gitbook xxxx in the Ubuntu terminal, how can I run it from my PHP code?
If you run php by nginx or apache (for example, visit url example.com/index.php), sometime you need to export the PATH
exec("export PATH=/usr/local/bin && gitbook build);
after I added export PATH, everything works fine.
I tried once like this on UNIX-based OS:
You can run shell commands via the exec() function:
// make an php file to execute shell script
exec("node yourscript.js &", $output);
Well output here become array of each line of output along with process id. You can kill process by processid also.
exec("kill " . $processid);
This how I was did. Other then this you can use node supervisor. Hope it will help you. Try your also with node command.
I have tried to run the Github: https://github.com/atbaker/wikipedia-question-generator
I have created the virtual environment using the following instruction: https://github.com/atbaker/wikipedia-question-generator#installing-with-python-34
$ pyvenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python -m textblob.download_corpora
Install the command line tool so you can use the tool easily:
$ pip install -e folder_name
Now the environment is completed.
My code ran properly on the commandline using the following:
wikitrivia 'tony'
Now I have tried to use it using php shell script as follows:
<? php
$out = shell_exec('wikitrivia "tony" ');
echo $out;
?>
But there is nothing on the output screen. I tried to run the command php -v and have shown the version. But the command wikitrivia "tony" is not working. I am using AWS Ubuntu environment.
My php version is 7 and the python version is 3.5
Hope this helps. Kindly, let me know what I can do?
I did it recently as a cron task.
You need to execute script from working dir with interpreter from venv.
Somethin like that:
<? php
$out = shell_exec('cd FULL_YOUR_PYTON_WORKING_DIR && YOUR_VENV/bin/python FULL_PATH_TO_YOUR_SCRIPT.py "tony"');
echo $out;
?>
I'm using CentOS, and I am able to execute php via CLI from the terminal, but when I run the exact same command via exec(), and it appears that the Memcached class doesn't exist.
so this works:
~$ php script.php args
But this doesn't:
exec('php script.php args');
Anyone have any ideas why it behaves differently in these cases?
PS: I've tried specifying the ini file like this:
exec('php -c /etc/php.ini script.php args');
This was fixed by reinstalling memecache... I'm not sure why or how that worked.
Normally when I want to run a php script from the command line I just create a php page, add a shebang pointing to the php binary, then ./file.php to run it. Since I have php installed as an apache module, I'm not even sure what my shebang should look like. Any ideas?
The CLI version of PHP had been part of the default installation since 4.3 and has to be explicitly turned off when PHP is being built. If you have access to the command line try
$ php -v
If you don't get a command not found error then you should be ready to go.
To actually run a php file from the command line do this:
$ php -f file.php
If it's just an Apache module, I don't think you can do it… At least, not without using a script like this:
$ cat run_php_with_apache
#!/bin/sh
cp "$1" /var/www/
curl "http://localhost/`basename "$1"`"
rm "/var/www/`basename "$1"`"