LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices


Reply
  Search this Thread
Old 05-02-2006, 11:35 AM   #1
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Rep: Reputation: 15
Question running script to bring up wireless card


I would like to run the following script on boot:
#!/bin/bash
#
# Network Script
#
iwconfig wlan0 mode Managed
iwconfig wlan0 key restricted 9138032573
ifup wlan0
exit

I have run each individual command in terminal and my card comes up. However, when I run the script the card fails to come up and tell me determining ip inof failed no link present check cable.

Why would running each individaul command work but in a script it fails? also, once I get the script to run properly, how do I set up a link in /etc/rc.d/rc5.d to run on boot?

Is this correct >
ln -s /etc/rc.d/rc.d5.d/S100myNetworkScript /etc/rc.d/init.d/myNetworkScript
 
Old 05-03-2006, 05:10 AM   #2
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
firstly:

Quote:
ln -s /etc/rc.d/rc.d5.d/S100myNetworkScript /etc/rc.d/init.d/myNetworkScript
no... it's the other way round.

ln -s /etc/rc.d/init.d/yourscript /etc/rc.d/rc5.d/S123yourscript




you don't need exit in your script. Not sure about the other bit. when are you runing it?
 
Old 05-03-2006, 05:18 AM   #3
bernied
Member
 
Registered: Mar 2006
Location: Edinburgh, UK
Distribution: debian
Posts: 304

Rep: Reputation: 30
Maybe in the script the ifup command is executed before the iwconfig commands have finished.
So a wait command would do the trick. Does this work?

Not sure there what wait does though. Looks like it waits for a process. Maybe
Code:
wait ifconfig
Or
Code:
sleep 5
I haven't tried any of this, so take care.
 
Old 05-03-2006, 06:36 AM   #4
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
the script wont progress onto the next command until the one before is finished... but you could try putting a sleep in there....
 
Old 05-03-2006, 12:26 PM   #5
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 15
I separated them into two scripts which works when I run them manually, but it is not working on bootup. I put the link into rc5.d.
 
Old 05-03-2006, 01:55 PM   #6
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
i'd do it earlier in the boot process....

what's your link?
 
Old 05-03-2006, 02:26 PM   #7
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 15
here is my link in rc5.d >
ln -s /etc/rc.d/init.d/myNetworkScript /etc/rc.d/rc5.d/S123myNetworkScript

by the way sleep worked
 
Old 05-03-2006, 07:20 PM   #8
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 15
I ended up putting it into /etc/rc.d/rc.local and it works
 
Old 05-04-2006, 08:08 AM   #9
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Rep: Reputation: 30
doesn't your distro have an interfaces file where this can be done?
 
Old 05-04-2006, 11:32 PM   #10
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 15
how do I find out where the interfaces file is?
 
Old 05-05-2006, 01:44 AM   #11
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
well, which distro are you using?
 
Old 05-05-2006, 05:23 AM   #12
bernied
Member
 
Registered: Mar 2006
Location: Edinburgh, UK
Distribution: debian
Posts: 304

Rep: Reputation: 30
I suspect that your script called by the link 'S123...' will execute early rather than late, because those links are probably sorted alphabetically, so 'S123' would be between 'S10' and 'S20'. If you want it to run later, use 'S90'.

But then again, if it works, why mess with it?

/etc/network/interfaces
on Ubuntu, so probably Debian and other variants too

If you put your distro in your LQ profile, people will be able to help you better.
 
Old 05-05-2006, 05:24 AM   #13
bernied
Member
 
Registered: Mar 2006
Location: Edinburgh, UK
Distribution: debian
Posts: 304

Rep: Reputation: 30
and try
Code:
locate interfaces
 
Old 05-05-2006, 05:42 AM   #14
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
On many distro's you should base your script on a skeleton service script and use instserv to create the link. You may also have the chkconfig command which can be thought of as a front end to inserv when used to enable services at certain run levels. ( I don't know which distro you have ).

Also check if you have a /etc/sysconfig/network/ folder. There may be an ifcfg-wlan0 configuration file where you can set the values used by the device and let the system's startup script initalize the device and authenticate with the access point using wpa_supplicant.

The administrator's manual for your distro probably has the details on how this all works for your system.
 
Old 05-05-2006, 12:37 PM   #15
dlennon
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 15
I am running Fedora 5. I created ifcfg-wlan0 configuration file and that is when the card showed up in the Network Manager. I also did a number of things that other people suggested so that the card would start at boot. Unfortunately, at boot time it gives me the message that the link is not there and to check the cable. That is when I decided to run the script of the commands I use to bring up the link and get the ip address. Since it works this way I am inclned to go with the solution.
 
  


Reply

Tags
network, script



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
Start Up script for wireless running with Ndiswrapper mckinlsm Linux - Wireless Networking 3 10-20-2008 11:11 PM
Running Wireless modem card on LAN arnekasper Linux - Wireless Networking 3 09-09-2005 09:57 AM
An Ideal Wireless Card for Slackware 10.0 running 2.6.10 cddesjar Linux - Wireless Networking 7 02-22-2005 11:53 PM
wireless on Linux dying when I bring another wireless device in the LAN sal_paradise42 Linux - Wireless Networking 5 11-14-2004 03:38 AM
running C/C++ and installing wireless card suresh_reddy Linux - Laptop and Netbook 1 02-27-2004 05:16 PM

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

All times are GMT -5. The time now is 12:53 PM.

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