LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2010, 04:25 PM   #16
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28

Quote:
Originally Posted by EricTRA View Post
Hi,

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.
 
Old 05-21-2010, 10:21 PM   #17
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
AFAIK, it's:

# iwlist wlan0 scanning

not

iwlist wlan0 scan


$ man iwlist
 
Old 05-22-2010, 12:15 AM   #18
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Joe of Loath View Post
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?

Kind regards,

Eric
 
Old 05-22-2010, 10:12 AM   #19
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
Quote:
Originally Posted by EricTRA View Post
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?

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!
 
Old 05-22-2010, 10:40 AM   #20
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
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!

Thanks for your patience!
 
Old 05-22-2010, 10:45 AM   #21
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

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

Kind regards,

Eric
 
Old 05-22-2010, 11:45 AM   #22
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
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...
 
Old 05-22-2010, 11:53 AM   #23
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi Joe,

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.

Kind regards,

Eric
 
Old 05-22-2010, 11:57 AM   #24
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
If I log in via SSH it will run the script again, then most probably bork won't it? I might use one user to log in locally, and one remotely...

Thanks for all your help!

Last edited by Joe of Loath; 05-22-2010 at 12:00 PM.
 
Old 05-22-2010, 12:05 PM   #25
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

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
 
Old 05-22-2010, 02:35 PM   #26
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
Quote:
Originally Posted by EricTRA View Post
Hi,

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...
 
Old 05-23-2010, 04:20 AM   #27
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

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.

Kind regards,

Eric
 
Old 05-23-2010, 07:50 AM   #28
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
Quote:
Originally Posted by EricTRA View Post
Hello,

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.

Kind regards,

Eric
That's great, thanks so much!
 
Old 05-23-2010, 07:55 AM   #29
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

You're welcome, just try it out to see if it does the job and let us know your results here please.

Kind regards,

Eric
 
Old 05-24-2010, 02:14 PM   #30
Joe of Loath
Member
 
Registered: Dec 2009
Location: Bristol, UK
Distribution: Ubuntu, Debian, Arch.
Posts: 152

Original Poster
Rep: Reputation: 28
Ok, I'm getting this:

Code:
-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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
does Debian Lenny/sid support Debian Sarge Binary Installer..? @nthoon Debian 1 06-14-2009 10:47 AM
LXer: How To Upgrade A Debian Etch System (Server & Desktop) To Debian Lenny LXer Syndicated Linux News 0 02-20-2009 04:30 PM
LXer: The Perfect Server - Debian Lenny (Debian 5.0) [ISPConfig 2] LXer Syndicated Linux News 0 02-19-2009 11:00 AM
Reboot of Debian Lenny now Windows PCs cannot see Debian. sr_25 Debian 3 02-14-2009 02:03 PM
WPA in Debian h2gofast Debian 2 08-19-2005 10:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration