How to run roscore from php using shell script?

asked 2017-08-07 15:10:01 -0500

coolbeans gravatar image

updated 2017-08-08 01:54:21 -0500

gvdhoorn gravatar image

Hi, Need help to figure out how to execute roscore or launch files from the web.

To do this, I created startup.php that calls a startup.sh file from the web. This shell script calls the roscore command. The echo is printed out however, the roscore command does not run.

startup.php

<?php
if ($_GET['run']) {
  # This code will run if ?run=true is set.
  $output = shell_exec("sh /var/www/html/startup.sh");
  echo "<pre>$output</pre>";
}
?>
  # This code will run if ?run=true is set.
  $output = shell_exec("sh /var/www/html/ros_startup.sh");
  echo "<pre>$output</pre>";
}
?>
<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>

startup.sh

#!/bin/bash
clear
echo "Start..." 
source /opt/ros/kinetic/setup.bash
roscore
echo "Completed..."
edit retag flag offensive close merge delete

Comments

I replicated just the bash script and on it runs the roscore. Is there I am missing?

naveedhd gravatar image naveedhd  ( 2017-08-08 08:04:21 -0500 )edit