restart wifi , error in script - Raspberry Pi Forums
i want reboot wireless network when stops responding. found
script , when run get: line 3: [0: command not found
idea i'm doing wrong?
ping -c4 192.168.1.1 > /dev/null
if [ $? != 0 ]
then
echo "no network connection, restarting wlan0"
/sbin/ifdown 'wlan0'
sleep 5
/sbin/ifup --force 'wlan0'
fi
script , when run get: line 3: [0: command not found
idea i'm doing wrong?
ping -c4 192.168.1.1 > /dev/null
if [ $? != 0 ]
then
echo "no network connection, restarting wlan0"
/sbin/ifdown 'wlan0'
sleep 5
/sbin/ifup --force 'wlan0'
fi
try this
code: select all
#!/bin/bash router="192.168.1.1" ip_addr="192.168.1.5/24" /bin/ping -q -c1 $router > /dev/null if [ $? -eq 0 ] : # echo "network active" else echo "network down, fixing..." /bin/kill -9 `pidof wpa_supplicant` /sbin/ifup --force wlan0 /sbin/ifconfig "wlan0 $ip_addr" /sbin/ip route add default via $router dev wlan0 cat > /etc/resolv.conf <<resolver nameserver $router nameserver 8.8.8.8 search example.co.uk resolver fi
raspberrypi
Comments
Post a Comment