Advanced Utilities Exercise 3.2.1 Passing parameters to a bash script

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 . 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 file.

  • If the parameter is forward_backward, the script will execute the file.

  • If the parameter is square, the script will execute the 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$ ./
Please enter one of the following;
user:~/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts$ circle
bash: circle: command not found

Hi @Kozzix ,

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:

./ circle             # to perform circle move
./ forward_backward   # to perform font-back move
./ square             # to perform square move

You must first understand how terminal works before you can continue to make bash scripts.


I’m not sure what help this was. But thank you for the attempt.

Hi @Kozzix,

here is the possible content of script.



function help(){
    echo "Please enter one of the following: circle, forward, backward, square"
    echo "Example: ./ circle"
    exit 1

if [[ "$argument" == "circle" ]]; then
    echo "Well done, you typed CIRCLE"
elif [[ "$argument" == "square" ]]; then
    echo "Well done, you typed SQUARE"
    echo "Oh, you typed something else: $argument"

If you paste this content in a file ending with the .sh extension (example:, and then give it execute permissions with chmod +x, and run it with ./, it will tell you that the correct way of running would be:

./ circle

Please let us know it things are now clearer