I want to execute a script with a ProcessBuilder(). My code is:
new ProcessBuilder().inheritIO().command("/bin/bash", "-c", "./deploy.sh").start();
In the bash script I have:
#!/bin/bash
rosrun my_package ardrone_test_1.py
It works if I run the bash script manually in the terminal, but if I do with the ProcessBuilder I got an error:
rosrun: command not found
The same if I run python scripts which uses ROS. There are errors that some package are not found, whereas it works fine if run via terminal.
rosrun. You can have a look at Java ProcessBuilder not able to run Python script in Javarosrunmight be an alias, which wouldn't be resolved when callingbash -c rosrun. Usetype rosrunin the terminal where it works to find out. If it's an alias then stop relying on it and use the aliased command instead of the alias. If it's not,typewill tell you where the executable is and an easy fix would be to use that in the script instead of just rosrun