Go Down

Topic: Calling php process from sketch (Read 832 times) previous topic - next topic

takissd

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: [Select]
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: [Select]
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

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

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

or this

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

takissd

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?

Federico Fissore

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
Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Erni

Actually it is php-cli

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

Code: [Select]
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: [Select]
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

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

Now I am able to use it like this:

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

takissd

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy