Create package by shell script

Hello,
I’m trying to create all my_sphero packages with a shell script, so I wrote the first piece as follows, but some commands seem not to be recognized. Please, does anyone have a suggestion?

#!/bin/bash
roscd
cd …
cd src
catkin_create_pkg my_sphero_subscriber rospy
roscd my_sphero_subscriber
mkdir launch

user:~/catkin_ws/devel$ ./my_sphero_make_package_script.sh
./my_sphero_make_package_script.sh: line 2: roscd: command not found
Created file my_sphero_subscriber/package.xml
Created file my_sphero_subscriber/CMakeLists.txt
Created folder my_sphero_subscriber/src
Successfully created files in /home/user/catkin_ws/src/my_sphero_subscriber. Please adjust the values in package.xml.
./my_sphero_make_package_script.sh: line 6: roscd: command not found

Thanks
Salvatore

Hi @saxosun,

Have you tried to source your workspace before you launch the bash script? Or do you have roscore running in the background before you try to launch the bash script? I think that might be causing an issue.

1 Like

Hi @shahramnajam.neduet,
thanks for your hint. I’ve resolved in this way:

#!/bin/bash

cd /home/user/catkin_ws
source devel/setup.bash

roscd
cd …
cd src
catkin_create_pkg my_sphero_subscriber rospy
roscd my_sphero_subscriber
mkdir launch

Cheers
Salvatore

1 Like