system
October 23, 2013, 6:19pm
1
Hello all, i have a php file that i would like to run as a process from my sketch.
I have seen the process command with a lot of examples like :
void runCpuInfo() {
Process p;
p.begin("cat");
p.addParameter("/proc/cpuinfo");
p.run();
}
but i am not sure hot to run a php file from linux and if process is the right command to use from sketch cause something like this will not work:
void runphpfile() {
Process p;
p.begin("myfile.php");
p.run();
}
even from command line i cannot run it. I know if i try to hit the php file from the browser it runs fine.
Any pointers? thanks
Erni
October 24, 2013, 2:15pm
2
I have not tried with php, but with python this work:
p.runShellCommand("python /usr/bin/test.py 2>&1");
or this
Process p;
p.begin("python");
p.addParameter("/usr/bin/test.py");
p.run();
system
October 24, 2013, 5:04pm
3
Thanks for the reply. I know the python way, i am still trying to figure the php way.
the part: p.begin("php5"); doesnt seem to work for me...
Any other thoughts?
I think the command line program for php is php5-cli not just php5. Take a look at Arduino Playground - Yun
Erni
October 25, 2013, 8:52am
5
Actually it is php-cli
When I type php-cli -v on the commandline I get this response:
PHP 5.4.17 (cli) (built: Sep 12 2013 18:54:21)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
It also gives some warnings:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/pdo_sqlite.so' - Fil e not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/sqlite.so' - File no t found in Unknown on line 0
I will try to figure out what to do about these
Erni
October 25, 2013, 9:12am
6
Ok, the errors was due to a misconfigured php.ini file.
Now I am able to use it like this:
p.runShellCommand("php-cli /usr/bin/hello.php 2>&1");
system
October 25, 2013, 4:04pm
7
Thank you , i will give it a try at home!