Let me elaborate: I am trying to spawn the catkin_init_workspace from PHP, using the proc_open like so:
touch( "$dir/stderr.txt" );
chmod( "$dir/stderr.txt", 0755 );
$fp = fopen("$dir/stderr.txt", "w");
fclose($fp);
$descr = array(
0 => array("pipe", 'r'), // stdin
1 => array("pipe", 'w'), // stdout
2 => array("file", "$dir/stderr.txt", "w")to file
);
$pid = proc_open( "catkin_init_workspace", $descr, $pipes, $dir );
if (!is_resource( $pid) )
throw new Exception ( "`catkin_init_workspace` exec failed");
else if ( is_resource( $pid ) )
{
fclose( $pipes[1] );
$retval = proc_close( $pid );
}
The above code has worked with CMake, with GCC and other applications. However, when I try this with catkin_init_workspace, I get:
sh: 1: catkin_init_workspace: not found
Now, as far as I understand, catkin_init_workspace is a python script at:
/opt/ros/indigo/bin/catkin_init_workspace
I tried invoking it directly by using the absolute path, but that didn't work.
As a user, everything works fine. But not when I am executing via www-data, the user/group setup for Apache2.
ROS tutorial explain that I need to setup my environment variables, by running
source /opt/ros/indigo/setup.bash
Which I also tried doing via PHP, right before I invoke the proc_open, but to no avail. My understanding is that I need to setup the environment variables correctly.
Doing
export | grep ROS
shows:
declare -x ROSLISP_PACKAGE_DIRECTORIES="/home/alex/Projects/ros_ws/devel/share/common-lisp"
declare -x ROS_DISTRO="indigo"
declare -x ROS_ETC_DIR="/opt/ros/indigo/etc/ros"
declare -x ROS_MASTER_URI="http://localhost:11311"
declare -x ROS_PACKAGE_PATH="/home/alex/Projects/ros_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks"
declare -x ROS_ROOT="/opt/ros/indigo/share/ros"
declare -x ROS_TEST_RESULTS_DIR="/home/alex/Projects/ros_ws/build/test_results"
Are those the environment variables I need to setup for www-data to correctly invoke catkin?
If so, how do I pass as an env array to PHP's proc_open, those variables?