May Not Be Pretty, But It Works

So I sometimes have trouble connecting to or staying connected to the wifi network (not enantiomer).  I prefer doing things via commandline whenever I can, or writing my own scripts.

So, as the title says, this may not be very pretty, but I use it, it works.  I’m sort of proud of myself for knowing how to do most of it just off the top of my head.  Parts did involve some googling “how to _______” to get it done, but now I know how to do those too.\

It’s not really for debugging, like it says, and it’s not too interactive, but I really wanted to call it that.

echo Debugging Interactive Script
sleep 1
echo Bringing down wlan0
ifconfig wlan0 down
sleep 2
echo Bring up wlan0
ifconfig wlan0 up
echo Connect to NAME
iwconfig wlan0 essid NAME
echo Wait a couple seconds.
sleep 1; echo .; sleep 1; echo .; sleep 1; echo .; sleep 1; echo .; sleep 1
read -p "Press [ENTER] to continue."
sleep 2
echo Removing existing dhcpcd stuff
rm /var/run/
sleep 2
echo Run dhcpcd
dhcpcd wlan0
sleep 2
echo Ping the router, quiet
ping -w 3 -q -I wlan0
echo Did it work? Then ping google.
select yn in "Yes" "No"; do
  case $yn in
    Yes ) ping -w 3; break;;
    No ) exit;;
    * ) echo "Please answer yes or no.";;
read -p "Press [ENTER] to exit."

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s