Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 5644  / 2 Years ago, sun, january 16, 2022, 11:51:52

I'm facing problems with WIFI on ubuntu
i tried to update the system but still the same
what happens is that i suddenly lose the connection with my router
and when i press on the WIFI bar the system won't detect any APs
i have to uncheck "enable WIFI" option ,then re check it so it work,it automatically reconnect.



I'm thinking of making a bash script that detects when the pc is disconnected from the router for any reason, and when it is disconnected it disable then enable the wifi.
i mean like automating resetting the connection that possible ?



i guess i must use this



nmcli nm wifi off
nmcli nm wifi on


but how can i make the script know if the PC is disconnected from the WIFI ?


More From » wireless

 Answers
7

It is more simple than you think:



#!/bin/bash

if ! [ "$(ping -c 1 google.com)" ]; then
nmcli nm wifi off
nmcli nm wifi on
fi


Then you can use a cron job for this script to run at every minute.


[#28457] Tuesday, January 18, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hical

Total Points: 498
Total Questions: 106
Total Answers: 117

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
hical questions
Sun, May 9, 21, 00:59, 3 Years ago
Fri, Jun 25, 21, 03:06, 3 Years ago
Thu, May 19, 22, 15:32, 2 Years ago
;