#!/bin/bash
ARG1=$1
if ["$ARG1" == “small_square”]; then
echo "Drawing small square"
rosrun linux_exam small_square.py
elif ["$ARG1" == “medium_square”]; then
echo "Drawing medium square"
rosrun linux_exam medium_square.py
elif ["$ARG1" == “big_square”]; then
echo "Drawing big square"
rosrun linux_exam big_square.py
fi
everytime I try to run the above bash script, it gives me this error:
./task2.sh: line 8: [big_square: command not found
./task2.sh: line 12: [big_square: command not found
./task2.sh: line 16: [big_square: command not found
Any suggestion to solve this will be highly appreciated (I have been stuck to this issue for too long).
Cheers.
Hello dsdjoy4,
The problem is the lack of space before the “$ARG1” and after the “small_square”. Press the space bar just once as shown in the code below and the problem would be solved. Cheers.
#!/bin/bash
ARG1=$1
if [ "$ARG1" == "small_square" ]; then
echo "Drawing small square";
rosrun linux_exam small_square.py
elif [ "$ARG1" == "medium_square" ]; then
echo "Drawing medium square";
rosrun linux_exam medium_square.py
elif [ "$ARG1" == "big_square" ]; then
echo "Drawing big square";
rosrun linux_exam big_square.py
fi
3 Likes
Do this for small, medium and big square
1 Like
Thank you for the reply Yelaina. Really appreciate it.
I have now tried putting one space character, unfortunately still same error:
./task2.sh: line 8: [big_square: command not found
./task2.sh: line 12: [big_square: command not found
./task2.sh: line 16: [big_square: command not found
@dsdjoy4, I dont think you got what I explained. Try running the code I pasted and then carefully compare it with your code and you would see the error I am referring to. Cheers.
2 Likes
Oh I see, Thank you so much @Yelaina. Big Help! : )
2 Likes
@dsdjoy4 …You are welcome!
1 Like