Reputation: 526
#!/bin/bash
A='';B='';C='';D=''
function returnFunctionWebService()
{
touch test.json
curl http://localhost:9099/BelattarProject/StudentMail.php -o test.json
for line in `cat test.txt`;do
echo $line
A=$(echo $line | cut -d ',' -f1)
echo $A
B=$(echo $line | cut -d ',' -f2)
echo $B
C=$(echo $line | cut -d ',' -f3)
echo $C
D=$(echo $line | cut -d ',' -f4)
echo $D
done
}
returnFunctionWebService
echo $A $B $C $D
if [ -n $A ]; then
if(( "$A" = "\"test1\"" )); then
echo -e "c'est juste"
exit
else
echo -e "c'est pas juste"
exit
fi
fi
i have an error at this end which is ./scriptWeb.sh: line 22: ((: "test1" = "test1" : syntax error: operand expected (error token is ""test1" = "test1" ") some help please
Upvotes: 3
Views: 82
Reputation: 43039
(( ))
can only be used for integer arithmetic, not for string comparisons. For strings, use [[ ]]
construct, this way:
if [[ "$A" = "\"test1\"" ]]; then
There are many issues in your script. Get it checked at shellcheck
See also:
Upvotes: 4