This is the shell code I am running:
#!bin/bash
while true
do
req=$(curl http://localhost/devcalls/camerarequest.php)
if [ "$req" == "1" ]
then
sudo bash /home/ckoy-admin/HAS_system/camera/cam.sh
fi
done
and this is the error I get when I execute:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1 100 1 0 0 56 0 --:--:-- --:--:-- --:--:-- 58
CAM.sh: 7: [: 1: unexpected operator
Please let me know what is wrong here.
if [ "$req" = 1 ]
or even better
if [ "$req" -eq 1 ]
See the syntax and operators in man test.
To compare INTEGER
if [ "$req" -eq 1 ]
To compare STRING
if [ "$req" = "string" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With