Im trying to execute a Python script to get and set the parameter server in ROS. When I run any other simple python script that for example prints "Hello", I get back the value in PHP. But when I run this code:
#!/usr/bin/env python
import roslib
import rospy
import sys
import re
import string
get = rospy.get_param("param")
print get
I get an empty echo. However this code works fine in the terminal!
All I'm doing in PHP is:
$output = exec("python path/script.py")
echo $output;
I tried shell_exec, I tried with python in the command, and without. I also tried /usr/bin/python still it won't work for this specific code, but everything works for a simple print!
It turns out that Apache's user doesnt have the required environment variables. So you have to add the environment variables paths you need in Apache's.. You can set them out here