View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 3 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue Sep 14, 2010 2:47 am 
Offline
Joined: Sun Aug 28, 2005 7:07 pm
Posts: 821
Location: Melbourne, Australia
Hi all,

Here is a script I use to automatically (re)connect to my wireless network. Anything in angled brackets should be replaced with the value of course:

1. Save the following as /usr/local/bin/checkwireless.sh

Code:
#!/bin/bash
echo "Check essid..."
if [ `iwconfig wlan0|grep ESSID|awk -F: '{print $2}'` = "\"<your_ESSID>\"" ]
then
   echo "essid has been set"
else
   echo "essid has not been set. Setting..."
   sleep 1
   iwconfig wlan0 key restricted <your-network-pass>
   iwconfig wlan0 essid "<your_ESSID>"
   sleep 1
   echo "done."
fi
# next line assumes you have a 192.168 internal address, hence 168
if [ `ifconfig wlan0|grep 168|wc -l` -eq 1 ]
then
   echo "ip address already set. Skipping."
else
   echo "ip address for wlan0 not set. Setting manually ..."
   ifconfig wlan0 192.168.<your-IP>
   sleep 1
   route add default gw 192.168.<default-gateway>
   echo "done."
fi
if [ `grep name /etc/resolv.conf|wc -l` -eq 1 ]
then
        echo "nameserver already set. Skipping"
else
   echo "nameserver not set. Setting now"
        echo 'nameserver 192.168.<your-nameserver>' > /etc/resolv.conf
fi


To get this working, I added it to root's crontab. As root, type "crontab -e", then add this:
Code:
* * * * * /usr/local/bin/checkwireless.sh 1>/var/log/wireless.log


This will check every minute. If your wireless isn't as unreliable as mine, change the first * (minutes) to something like a number between 0 and 59 (hourly, at whatever past) or */4 (etc.) for every 4 minutes, starting on the hour.

_________________
*********************
LinHES 7.4
Australian Dragon
*********************


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2010 9:25 pm 
Offline
Joined: Wed Mar 07, 2007 9:51 am
Posts: 173
Location: Uniontown, PA
mike...

If this wireless problem is because of an unstable router, I'd suggest that you tear it apart and see if the Caps are going bad.

I purchased a Netgear DG834G DSL Modem/Wireless/Router, and was having trouble keeping an 11mb wireless connection going. It would drop to 2mb, then 5mb, then 1mb then 11mb and it would drop the connection on a regular basis. I decided to open it up and the caps were bulging...so I replaced them, and I haven't had any trouble since! :)

I have about 15 wireless devices on my home net, so it was causing me some major grief. After changing the caps, everything is happy and ON-LINE at high speed!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2010 11:12 pm 
Offline
Joined: Sun Aug 28, 2005 7:07 pm
Posts: 821
Location: Melbourne, Australia
larrybpsu wrote:
If this wireless problem is because of an unstable router, I'd suggest that you tear it apart and see if the Caps are going bad.

Thanks but it's been like that since new (opened the shrink wrap less than 6 months ago). The wireless bridge I had before was a lot more reliable, but unencrypted and therefore ended up quite expensive (damned freeloading neighbours). I'm sure it's a compatibility thing: My Google phone works brilliantly with the router at full speed and from much further away than the Dragon is.

The script actually works quite well, so as a geek diagnosing and solving (well, working around) the problem was a good way to spend a few hours.

Mike

_________________
*********************
LinHES 7.4
Australian Dragon
*********************


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu