Pages: [1]   Go Down
Author Topic: Calling php process from sketch  (Read 532 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :
Code:
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:

Code:
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

Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1029
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not tried with php, but with python this work:

Code:
p.runShellCommand("python /usr/bin/test.py 2>&1");

or this

Code:
  Process p;
  p.begin("python");
  p.addParameter("/usr/bin/test.py");
  p.run();
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
God Member
*****
Karma: 12
Posts: 632
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the command line program for php is php5-cli not just php5. Take a look at http://playground.arduino.cc/Hardware/Yun#installing_php
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1029
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually it is php-cli

When I type php-cli -v on the commandline I get this response:

Code:
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:

Code:
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
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1029
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, the errors was due to a misconfigured php.ini file.

Now I am able to use it like this:

Code:
p.runShellCommand("php-cli /usr/bin/hello.php  2>&1");
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you , i will give it a try at home!
Logged

Pages: [1]   Go Up
Jump to: