-   Linux - Wireless Networking (
-   -   running script to bring up wireless card (

dlennon 05-02-2006 12:35 PM

running script to bring up wireless card
I would like to run the following script on boot:
# Network Script
iwconfig wlan0 mode Managed
iwconfig wlan0 key restricted 9138032573
ifup wlan0

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

satinet 05-03-2006 06:10 AM



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?

bernied 05-03-2006 06:18 AM

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

wait ifconfig

sleep 5
I haven't tried any of this, so take care.

satinet 05-03-2006 07:36 AM

the script wont progress onto the next command until the one before is finished... but you could try putting a sleep in there....

dlennon 05-03-2006 01:26 PM

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.

satinet 05-03-2006 02:55 PM

i'd do it earlier in the boot process....

what's your link?

dlennon 05-03-2006 03:26 PM

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

dlennon 05-03-2006 08:20 PM

I ended up putting it into /etc/rc.d/rc.local and it works

short101 05-04-2006 09:08 AM

doesn't your distro have an interfaces file where this can be done?

dlennon 05-05-2006 12:32 AM

how do I find out where the interfaces file is?

satinet 05-05-2006 02:44 AM

well, which distro are you using?

bernied 05-05-2006 06:23 AM

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?

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.

bernied 05-05-2006 06:24 AM

and try

locate interfaces

jschiwal 05-05-2006 06:42 AM

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.

dlennon 05-05-2006 01:37 PM

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.

All times are GMT -5. The time now is 09:24 PM.