I have no idea what we are doing here. Did I miss a lesson? I have already searched and found one other question about this but that confused me even more.
" For instance, let’s have a look at the script you used in this first demo, called demo.sh . I will just tell you the location of the script. It’s in the following path: /home/simulations/public_sim_ws/src/all/ros_basics_examples/linux_demo/ .
The rest you should be able to do by yourself at this point." Why would I be able to do this when we haven’t learned it?
There is no demo script in this lesson, that pathway is not in this lesson. I am completely lost.
“” Create a bash script that does the following:
It will receive one parameter, which will contain either:
circle
forward_backward
square
If the parameter is circle, the script will execute the move_bb8_circle.py file.
If the parameter is forward_backward, the script will execute the move_bb8_forward_backward.py file.
If the parameter is square, the script will execute the move_bb8_square.py file.“”
I tried this and was able to get this to print enter circle, forward etc… But when I entered circle it just gave me an error.
Can someone please help me. Thank you. Jason
user:~/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts$ ./thebash.sh Please enter one of the following; circle forward_backward square user:~/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts$ circle bash: circle: command not found user:~/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts$
I believe that you have not understood bash programming. Also I think you do not know how to use the terminal.
The instructions for you is to pass the shape as a command line operator.
So your command will look like below:
./my_bash_script.sh circle # to perform circle move
./my_bash_script.sh forward_backward # to perform font-back move
./my_bash_script.sh square # to perform square move
You must first understand how terminal works before you can continue to make bash scripts.
here is the possible content of thebash.sh script.
#!/bin/bash
argument=$1
function help(){
echo "Please enter one of the following: circle, forward, backward, square"
echo
echo "Example: ./thebash.sh circle"
exit 1
}
if [[ "$argument" == "circle" ]]; then
echo "Well done, you typed CIRCLE"
elif [[ "$argument" == "square" ]]; then
echo "Well done, you typed SQUARE"
else
echo "Oh, you typed something else: $argument"
help
fi
If you paste this content in a file ending with the .sh extension (example: test.sh), and then give it execute permissions with chmod +x test.sh, and run it with ./test.sh, it will tell you that the correct way of running would be: