What this Code means in module 2 milestone 1

if test $# -ne 1
then
echo “Incorrect invocation of script. Usage: ./check_QBox_server_memory.sh /proc/meminfo”
exit 1 # Failure
fi
we have to change this code??

No. You dont have to change that code. But understanding that piece of code is very important!

but after running my code , it always terminate after matching the first if statement i.e Incorrect invocation of script. Usage: ./check_QBox_server_memory.sh /proc/meminfo.

Just Understand the word Usage . You will get the point.

you have to pass an argument while executing the script.

i have figure it out

1 Like

hey,how did u solve ur error ,facing same issues

please run by following command
./check_QBox_server_memory.sh /proc/meminfo

it’s showing permissions denied. I even tried to change the permissions but that too even failed.

use chmod before running

I am having the same problem. but chmod is not working for proc/meminfo. So, can you tell me some another way, as output is coming but with permission denied.
And what is the use of cat $1. And how to use it. I am unable to get that TODO

./check_QBox_server_memory.sh: line 22: =MemTotal:: command not found
./check_QBox_server_memory.sh: line 23: test: -ge: unary operator expected
Error: Total Memory of KB is insufficient for QBox

I’m getting this type of output while executing file. What should i do ?

error in line 23 means that your variable totalMemInKb is empty, which means that you have check the line where you are finding the available memory.
error of unary operator expected is occurring most probably because your variable totalMemInKb is empty and the comparison is done with a null value and an integer.