Article 55JSY Script to check ip route

Script to check ip route

by
cadillacrick
from LinuxQuestions.org on (#55JSY)
Hey guys, first time post...

I'm trying to get a script to check if a route exists after I connect a VPN... First time trying to get this done and need some help...

This is what I have so far --

Code:#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
EXIST='ip route show 10.10.200.0/24 | wc -l'

if [$EXIST -eq 0]
then
echo "--- Route is down ---"
ip route add 10.10.200.0/24 via ppp1
fi

if [$EXIST -eq 1]
then
echo "---Route Enabled---"

fi
exit
Getting these errors when I try and run it...

./routecheck.sh: line 5: [ip: command not found
./routecheck.sh: line 11: [ip: command not found

If I run my command 'ip route show 10.10.200.0/24 | wc -l' it works fine.. i get a value of 1 when the route is active... but for some reason in the script it doesn't work... i'm sure i'm missing something stupid here.. but i'm new to this... so I need help please.

Thanks!

Richardlatest?d=yIl2AUoC8zA latest?i=xZfiWZ5PF7k:Kal4SzLRlQg:F7zBnMy latest?i=xZfiWZ5PF7k:Kal4SzLRlQg:V_sGLiP latest?d=qj6IDK7rITs latest?i=xZfiWZ5PF7k:Kal4SzLRlQg:gIN9vFwxZfiWZ5PF7k
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments