Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I assumed from this that you got it up and running. What are you 'struggling' with?
Kind regards,
Eric
Sorry, I posted before a reboot, and when I rebooted the script didn't run, I think I'm doing something wrong.
This is what I have:
Code:
echo Connecting
wpa_supplicant (the options go here, I powered my box off so don't have them to hand)
wait 5
echo Obtaining IP address through DHCP
dhclient wlan0
wait 3
Last edited by Joe of Loath; 05-21-2010 at 04:28 PM.
Sorry, I posted before a reboot, and when I rebooted the script didn't run, I think I'm doing something wrong.
Hello,
What did you do to make your script run at boot? Make a startupscript in the correct runlevel directory(ies)? Add it to your .bashrc/profile file? Add it to rc.local?
What did you do to make your script run at boot? Make a startupscript in the correct runlevel directory(ies)? Add it to your .bashrc/profile file? Add it to rc.local?
Kind regards,
Eric
I can't actually find where I put it now... I do know, however, I put it under runlevel 3, and debian boots to runlevel 2 as default. Looks like I just need to do poke around some more!
Ok, I saved the script as /etc/init.d/wlan, then did ln -s /etc/init.d/wlan /etc/rc2.d/wlan, aaanndd... It didn't work... I'm afraid after 2 years of using solely Linux I'm still hopeless at getting stuff to run on boot!
There are several options. You can create a startup script (using the skeleton in /etc); you can add a line to the file /etc/rc.local which will make the script run at boot for everyone; you can add a line to your /home/username/.bashrc file to start the script only for your user.
To install the startup script in Debian you use update-rc.d
Dodgy scriptwriting strikes again, I borked it... (Puppy Linux to the rescue! Again.) I'm going to add it to bashrc instead of using update-rc.d I think...
That's the easiest option indeed, and also it'll only startup your wireless for your user. So if you have more then one login/user then don't forget to put it in their bashrc file also if they need wireless.
You could do that or you could adapt your script so that it checks if the wlan0 card already is up or not. If it's up then do nothing, if it's not then execute the commands necessary. That would avoid the hassle of having two users; one local and one you user remotely. Also if you logged in before as the 'local user' and then next as the remote user you'll have the same situation, the wlan0 would already be up. To avoid this you could put a line in .bashrc_logout that brings down the wlan0; that is if you want to stick with the 'two user' option. I think it'll be a lot easier to just change your script to see if the wlan0 is up and act on that information.
You could do that or you could adapt your script so that it checks if the wlan0 card already is up or not. If it's up then do nothing, if it's not then execute the commands necessary. That would avoid the hassle of having two users; one local and one you user remotely. Also if you logged in before as the 'local user' and then next as the remote user you'll have the same situation, the wlan0 would already be up. To avoid this you could put a line in .bashrc_logout that brings down the wlan0; that is if you want to stick with the 'two user' option. I think it'll be a lot easier to just change your script to see if the wlan0 is up and act on that information.
And you're welcome, I'm glad to be of assistance.
Kind regards,
Eric
Ok, 'Revenge of the Noob' time. I can't do variables I know the logic, just not how to implement it...
Put the following in your script to check for a connection and if none is found then bring up the wireless:
Code:
check_ping=`ping -c1 google.com 2>&1 | grep unknown`
if [ ! "$check_ping" = "" ]; then
echo "It's down!! Start it up!!.
<place your commands here>
fi
This little conditional check will try to ping google.com. If there is connection the unknown will not be encountered in the output and nothing will be done. If on the other hand there is no connection to the internet ping will return unknown host google.com (or something like that) and next with your commands in place will bring up the wireless.
This should take care of being able to use the same user both locally and remotely without trying to start up the wireless whenever you open a second connection.
Put the following in your script to check for a connection and if none is found then bring up the wireless:
Code:
check_ping=`ping -c1 google.com 2>&1 | grep unknown`
if [ ! "$check_ping" = "" ]; then
echo "It's down!! Start it up!!.
<place your commands here>
fi
This little conditional check will try to ping google.com. If there is connection the unknown will not be encountered in the output and nothing will be done. If on the other hand there is no connection to the internet ping will return unknown host google.com (or something like that) and next with your commands in place will bring up the wireless.
This should take care of being able to use the same user both locally and remotely without trying to start up the wireless whenever you open a second connection.
-bash: /home/joe/.bashrc: line 104: unexpected EOF while looking for matching `"'
-bash: /home/joe/.bashrc: line 110: syntax error: unexpected end of file
This is what I put in my .bashrc file:
Code:
#Wlan setup
check_ping=`ping -c1 192.168.11.1 2>&1 | grep unknown`
if [ ! "$check_ping" = "" ]; then
echo "It's down!! Start it up!!.
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant -D wext -qq
wait 5
dhclient
wait 3
fi
No idea what's up... Should I have put the script in another file and set the .bashrc file to simply run that file?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.