wifi auto reconnection

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












usually wifi reconnects after dropping,but sometimes it will show the wifi log in screen already filled in,waiting to press on connect after that a new connection will form with #2 after the duplicate ssid.



sometimes i just untick/tick the 'enable networking'.other times,it wont reconnect.



i tried to form a script,but it continues to accumulate & count even when there is no badpings before reaching the max limit of 30 counts.



while true; 
do
if ! [ "$(ping -c 1 google.com)" ]; then
echo "no ping,will reset"

#counter of bad pings here
count=1
while [ $count -lt 30 ]
do
count=`expr $count + 1`
echo "$count"
# insert here: retest for good ping
sleep 1
done


nmcli networking off
sleep 5
nmcli networking on


#sleep for 15sec wait wifi on ssid search
secs=$((1 * 15))
while [ $secs -gt 0 ]; do
echo -ne "$secs33[0Kr"wifi reactivate in-
sleep 1
: $((secs--))
done


if ! [ "$(ping -c 1 google.com)" ]; then
echo "still offline for $count x @ $(date)"

else
count=0
#echo "reconnected at $(date)"
echo "ON"
fi
else

echo "ONLINE"
sleep 1
clear
fi
done






share|improve this question





















  • The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
    – Jesse_b
    Jul 18 at 18:49











  • Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
    – Kevin Kruse
    Jul 18 at 18:52










  • @KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
    – neowiz
    Jul 18 at 19:19










  • objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
    – neowiz
    Jul 18 at 19:32










  • What OS? Do you know why your signal is disconnecting? Your approach seems hackish
    – FreeSoftwareServers
    Jul 18 at 21:53
















up vote
1
down vote

favorite












usually wifi reconnects after dropping,but sometimes it will show the wifi log in screen already filled in,waiting to press on connect after that a new connection will form with #2 after the duplicate ssid.



sometimes i just untick/tick the 'enable networking'.other times,it wont reconnect.



i tried to form a script,but it continues to accumulate & count even when there is no badpings before reaching the max limit of 30 counts.



while true; 
do
if ! [ "$(ping -c 1 google.com)" ]; then
echo "no ping,will reset"

#counter of bad pings here
count=1
while [ $count -lt 30 ]
do
count=`expr $count + 1`
echo "$count"
# insert here: retest for good ping
sleep 1
done


nmcli networking off
sleep 5
nmcli networking on


#sleep for 15sec wait wifi on ssid search
secs=$((1 * 15))
while [ $secs -gt 0 ]; do
echo -ne "$secs33[0Kr"wifi reactivate in-
sleep 1
: $((secs--))
done


if ! [ "$(ping -c 1 google.com)" ]; then
echo "still offline for $count x @ $(date)"

else
count=0
#echo "reconnected at $(date)"
echo "ON"
fi
else

echo "ONLINE"
sleep 1
clear
fi
done






share|improve this question





















  • The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
    – Jesse_b
    Jul 18 at 18:49











  • Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
    – Kevin Kruse
    Jul 18 at 18:52










  • @KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
    – neowiz
    Jul 18 at 19:19










  • objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
    – neowiz
    Jul 18 at 19:32










  • What OS? Do you know why your signal is disconnecting? Your approach seems hackish
    – FreeSoftwareServers
    Jul 18 at 21:53












up vote
1
down vote

favorite









up vote
1
down vote

favorite











usually wifi reconnects after dropping,but sometimes it will show the wifi log in screen already filled in,waiting to press on connect after that a new connection will form with #2 after the duplicate ssid.



sometimes i just untick/tick the 'enable networking'.other times,it wont reconnect.



i tried to form a script,but it continues to accumulate & count even when there is no badpings before reaching the max limit of 30 counts.



while true; 
do
if ! [ "$(ping -c 1 google.com)" ]; then
echo "no ping,will reset"

#counter of bad pings here
count=1
while [ $count -lt 30 ]
do
count=`expr $count + 1`
echo "$count"
# insert here: retest for good ping
sleep 1
done


nmcli networking off
sleep 5
nmcli networking on


#sleep for 15sec wait wifi on ssid search
secs=$((1 * 15))
while [ $secs -gt 0 ]; do
echo -ne "$secs33[0Kr"wifi reactivate in-
sleep 1
: $((secs--))
done


if ! [ "$(ping -c 1 google.com)" ]; then
echo "still offline for $count x @ $(date)"

else
count=0
#echo "reconnected at $(date)"
echo "ON"
fi
else

echo "ONLINE"
sleep 1
clear
fi
done






share|improve this question













usually wifi reconnects after dropping,but sometimes it will show the wifi log in screen already filled in,waiting to press on connect after that a new connection will form with #2 after the duplicate ssid.



sometimes i just untick/tick the 'enable networking'.other times,it wont reconnect.



i tried to form a script,but it continues to accumulate & count even when there is no badpings before reaching the max limit of 30 counts.



while true; 
do
if ! [ "$(ping -c 1 google.com)" ]; then
echo "no ping,will reset"

#counter of bad pings here
count=1
while [ $count -lt 30 ]
do
count=`expr $count + 1`
echo "$count"
# insert here: retest for good ping
sleep 1
done


nmcli networking off
sleep 5
nmcli networking on


#sleep for 15sec wait wifi on ssid search
secs=$((1 * 15))
while [ $secs -gt 0 ]; do
echo -ne "$secs33[0Kr"wifi reactivate in-
sleep 1
: $((secs--))
done


if ! [ "$(ping -c 1 google.com)" ]; then
echo "still offline for $count x @ $(date)"

else
count=0
#echo "reconnected at $(date)"
echo "ON"
fi
else

echo "ONLINE"
sleep 1
clear
fi
done








share|improve this question












share|improve this question




share|improve this question








edited Jul 18 at 18:50









Jesse_b

10.1k22658




10.1k22658









asked Jul 18 at 18:27









neowiz

61




61











  • The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
    – Jesse_b
    Jul 18 at 18:49











  • Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
    – Kevin Kruse
    Jul 18 at 18:52










  • @KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
    – neowiz
    Jul 18 at 19:19










  • objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
    – neowiz
    Jul 18 at 19:32










  • What OS? Do you know why your signal is disconnecting? Your approach seems hackish
    – FreeSoftwareServers
    Jul 18 at 21:53
















  • The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
    – Jesse_b
    Jul 18 at 18:49











  • Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
    – Kevin Kruse
    Jul 18 at 18:52










  • @KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
    – neowiz
    Jul 18 at 19:19










  • objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
    – neowiz
    Jul 18 at 19:32










  • What OS? Do you know why your signal is disconnecting? Your approach seems hackish
    – FreeSoftwareServers
    Jul 18 at 21:53















The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
– Jesse_b
Jul 18 at 18:49





The if ! [ "$(ping -c 1 google.com)" ]; then line is flawed. What are you trying to accomplish there? This is always going to error and therefore be true since you are negating it.
– Jesse_b
Jul 18 at 18:49













Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
– Kevin Kruse
Jul 18 at 18:52




Your while [ $count -lt 30 ] does nothing except count to 30 and print the counter each time. What are you expecting it to do differently? Are you having trouble figuring out how to exit the while loop? Or are you asking how to test if the ping works?
– Kevin Kruse
Jul 18 at 18:52












@KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
– neowiz
Jul 18 at 19:19




@KevinKruse & Jesse_b I want to exit the count to 30 if there is a sudden good ping.
– neowiz
Jul 18 at 19:19












objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
– neowiz
Jul 18 at 19:32




objective: 1. the script will stay running in the background to check for wifi disconnection 2.It should count a max of 30 badpings (because sometimes its just having slow response time ) then it will reset wifi.. if there is a sudden good ping before reaching the 30max,reseting should halt and counter will go back to zero.
– neowiz
Jul 18 at 19:32












What OS? Do you know why your signal is disconnecting? Your approach seems hackish
– FreeSoftwareServers
Jul 18 at 21:53




What OS? Do you know why your signal is disconnecting? Your approach seems hackish
– FreeSoftwareServers
Jul 18 at 21:53










1 Answer
1






active

oldest

votes

















up vote
1
down vote













I think this is closer to what you want but can definitely be improved further:



while :; do
if ! ping -c1 google.com >/dev/null 2>&1; then
echo "no ping,will reset"
#counter of bad pings here
count=1
while [ "$count" -lt 30 ]; do
echo "$count"
# insert here: retest for good ping
nmcli networking off
sleep 5
nmcli networking on
if ! ping -c1 google.com >/dev/null 2>&1; then
echo "still offline for $count x @ $(date)"
else
#echo "reconnected at $(date)"
echo "ON"
break
fi
((count++))
sleep 1
done
else
echo "ONLINE"
sleep 1
clear
fi
done





share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457067%2fwifi-auto-reconnection%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    I think this is closer to what you want but can definitely be improved further:



    while :; do
    if ! ping -c1 google.com >/dev/null 2>&1; then
    echo "no ping,will reset"
    #counter of bad pings here
    count=1
    while [ "$count" -lt 30 ]; do
    echo "$count"
    # insert here: retest for good ping
    nmcli networking off
    sleep 5
    nmcli networking on
    if ! ping -c1 google.com >/dev/null 2>&1; then
    echo "still offline for $count x @ $(date)"
    else
    #echo "reconnected at $(date)"
    echo "ON"
    break
    fi
    ((count++))
    sleep 1
    done
    else
    echo "ONLINE"
    sleep 1
    clear
    fi
    done





    share|improve this answer



























      up vote
      1
      down vote













      I think this is closer to what you want but can definitely be improved further:



      while :; do
      if ! ping -c1 google.com >/dev/null 2>&1; then
      echo "no ping,will reset"
      #counter of bad pings here
      count=1
      while [ "$count" -lt 30 ]; do
      echo "$count"
      # insert here: retest for good ping
      nmcli networking off
      sleep 5
      nmcli networking on
      if ! ping -c1 google.com >/dev/null 2>&1; then
      echo "still offline for $count x @ $(date)"
      else
      #echo "reconnected at $(date)"
      echo "ON"
      break
      fi
      ((count++))
      sleep 1
      done
      else
      echo "ONLINE"
      sleep 1
      clear
      fi
      done





      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        I think this is closer to what you want but can definitely be improved further:



        while :; do
        if ! ping -c1 google.com >/dev/null 2>&1; then
        echo "no ping,will reset"
        #counter of bad pings here
        count=1
        while [ "$count" -lt 30 ]; do
        echo "$count"
        # insert here: retest for good ping
        nmcli networking off
        sleep 5
        nmcli networking on
        if ! ping -c1 google.com >/dev/null 2>&1; then
        echo "still offline for $count x @ $(date)"
        else
        #echo "reconnected at $(date)"
        echo "ON"
        break
        fi
        ((count++))
        sleep 1
        done
        else
        echo "ONLINE"
        sleep 1
        clear
        fi
        done





        share|improve this answer















        I think this is closer to what you want but can definitely be improved further:



        while :; do
        if ! ping -c1 google.com >/dev/null 2>&1; then
        echo "no ping,will reset"
        #counter of bad pings here
        count=1
        while [ "$count" -lt 30 ]; do
        echo "$count"
        # insert here: retest for good ping
        nmcli networking off
        sleep 5
        nmcli networking on
        if ! ping -c1 google.com >/dev/null 2>&1; then
        echo "still offline for $count x @ $(date)"
        else
        #echo "reconnected at $(date)"
        echo "ON"
        break
        fi
        ((count++))
        sleep 1
        done
        else
        echo "ONLINE"
        sleep 1
        clear
        fi
        done






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Jul 18 at 19:25


























        answered Jul 18 at 19:01









        Jesse_b

        10.1k22658




        10.1k22658






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457067%2fwifi-auto-reconnection%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay