0

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.

6
  • Have you called the setup script before? Are you sure the environment variables are set how they should? Commented Jun 14, 2019 at 15:03
  • Probably your environment is not setup properly, you should provide the path to rosrun. You can have a look at Java ProcessBuilder not able to run Python script in Java Commented Jun 14, 2019 at 15:07
  • @Kutschkem I run the script from the terminal and it works so I also assume all env variables are also set correctly, but I have already checked them, as well, and it seems fine. Commented Jun 14, 2019 at 15:14
  • @ButiriDan how I can provide a path to rosrun? I have seen the post you send me and I provide an absolute path when I run the python script, but it doesn't help, unfortunately. Commented Jun 14, 2019 at 15:18
  • rosrun might be an alias, which wouldn't be resolved when calling bash -c rosrun. Use type rosrun in 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, type will tell you where the executable is and an easy fix would be to use that in the script instead of just rosrun Commented Jun 14, 2019 at 15:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.