lundi 2 janvier 2017

invalid condition in the if statement [duplicate]

This question already has an answer here:

I need to simple script for VPN detecting on the Ubuntu. grep_output looks good, because returns 1 if any nmcli connection is active. Otherwise returns 0. The problem occures in 3rd line and script return information try.sh: 3: try.sh: [1: not found. Ive tried many combination with this condition but still doesnt work and always returns FALSE.

echo $grep_output returns 1

#!/bin/bash
grep_output="$(nmcli con show --active | grep HMA | wc -l)"
if [$grep_output -eq 1]
then
    echo "true - found VPN"
else
    echo "false - not found VPN"

fi
echo $grep_output

Aucun commentaire:

Enregistrer un commentaire