Networking Forums

Networking Forums > Computer Networking > Linux Networking > Problem scripting iwconfig

Reply
Thread Tools Display Modes

Problem scripting iwconfig

 
 
can2002
Guest
Posts: n/a

 
      04-22-2005, 05:41 PM
Hi,

I've got my ipw2100 wireless card working on my Tosh laptop and if I
manually type out a series of iwconfig commands I get it to connect to
my Access Point, as shown below:

iwconfig eth1 essid wireless
iwconfig eth1 key [3] s:123456790123
iwconfig eth1 key [3] restricted
iwconfig eth1 key [3]
dhclient eth1

My goal is to leave the default startup script unchanged so it will
automatically use DHCP without WEP in a wireless hotspot and create a
shell script to switch it to my home settings as above. The script I've
used is below:

#!/bin/bash
sudo iwconfig eth1 essid wireless
sudo iwconfig eth1 key [3] s:1234567890123
sudo iwconfig eth1 key [3] restricted
sudo iwconfig eth1 key [3]
sudo dhclient eth1

The above script will not work - I don't get an IP address and if I run
'iwconfig eth1' it indicates encryption is not enabled. If I then try
running the iwconfig commands again manually it's fine.

I am still quite new to Linux and this is one of my first attempts at
shell scripts, can anyone help with why it doesn't work?

Thanks in advance,
Chris
 
Reply With Quote
 
 
 
 
bram4
Guest
Posts: n/a

 
      04-22-2005, 05:55 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

can2002 wrote:
> Hi,
>
> I've got my ipw2100 wireless card working on my Tosh laptop and if I
> manually type out a series of iwconfig commands I get it to connect to
> my Access Point, as shown below:
>
> iwconfig eth1 essid wireless
> iwconfig eth1 key [3] s:123456790123
> iwconfig eth1 key [3] restricted
> iwconfig eth1 key [3]
> dhclient eth1
>
> My goal is to leave the default startup script unchanged so it will
> automatically use DHCP without WEP in a wireless hotspot and create a
> shell script to switch it to my home settings as above. The script I've
> used is below:
>
> #!/bin/bash
> sudo iwconfig eth1 essid wireless
> sudo iwconfig eth1 key [3] s:1234567890123
> sudo iwconfig eth1 key [3] restricted
> sudo iwconfig eth1 key [3]
> sudo dhclient eth1
>
> The above script will not work - I don't get an IP address and if I run
> 'iwconfig eth1' it indicates encryption is not enabled. If I then try
> running the iwconfig commands again manually it's fine.
>
> I am still quite new to Linux and this is one of my first attempts at
> shell scripts, can anyone help with why it doesn't work?
>
> Thanks in advance,
> Chris

Hi

Have you verified that for example
sudo iwconfig eth1 essid wireless
works when being run by a normal, i.e. non root user?

If it's not, then I think the problem is sudo...

Bram

- --


BIG BROTHER IS WATCHING YOU
www.anti-dmca.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCaSxpsv7ahDE9W98RAg6IAJ9X25iWkn0VjqiZQb0O8y W9fIPpEwCdFhax
s+vOJvXUwvnfot+XbutuSCQ=
=/aLS
-----END PGP SIGNATURE-----
 
Reply With Quote
 
can2002
Guest
Posts: n/a

 
      04-22-2005, 06:40 PM
bram4 wrote:
> Hi
>
> Have you verified that for example
> sudo iwconfig eth1 essid wireless
> works when being run by a normal, i.e. non root user?
>
> If it's not, then I think the problem is sudo...


Hi Bram,

I forgot to add to my last message that I've tried the shell script
without sudo (i.e. logging in as root and running it) but the same thing
happens.

I'll give what you suggest a try too just to play safe though.

Cheers,
Chris
 
Reply With Quote
 
Michael Heiming
Guest
Posts: n/a

 
      04-22-2005, 07:19 PM
In comp.os.linux.networking can2002 <can2002@nospammaildotnet>:
> Hi,


> I've got my ipw2100 wireless card working on my Tosh laptop and if I
> manually type out a series of iwconfig commands I get it to connect to
> my Access Point, as shown below:


[..]

> #!/bin/bash
> sudo iwconfig eth1 essid wireless
> sudo iwconfig eth1 key [3] s:1234567890123
> sudo iwconfig eth1 key [3] restricted
> sudo iwconfig eth1 key [3]
> sudo dhclient eth1


> The above script will not work - I don't get an IP address and if I run
> 'iwconfig eth1' it indicates encryption is not enabled. If I then try
> running the iwconfig commands again manually it's fine.


I'd put all commands without sudo in a script and call this via
sudo, just make sure your user has no write permissions to the
dir you put it in.

#!/bin/bash
# Bring up wireless interface

ifcf="/sbin/ifconfig"
iwdev="ra0"
iwcf="/usr/local/sbin/iwconfig"

/sbin/modprobe rt2500

$ifcf $iwdev inet 192.168.3.22 up

$iwcf $iwdev mode Ad-Hoc
$iwcf $iwdev enc restricted
$iwcf $iwdev key xxxxxxxxxxxxx
$iwcf $iwdev ap 00:00:22:22:22:22
$iwcf $iwdev essid "blah"
$iwcf $iwdev rate 54M
# Turn on wireless operation
$iwcf $iwdev mode 1

###

Just a quick hack, put together in a few minutes, I'm not using
wlan serious, just played around with it. The above works just
fine for my purposes. There's an ipw2200 card in a laptop, found
the wireless device among the most unstable/crappy devices ever
used. Probably because of the proprietary firmware, dmesg says
frequently "ipw2200: Firmware error detected. Restarting." This
is the moment wireless operation start to suck. Hope your card
works more reliable?

Good luck

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo (E-Mail Removed) | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 203: Write-only-memory subsystem too slow for
this machine. Contact your local dealer.
 
Reply With Quote
 
can2002
Guest
Posts: n/a

 
      04-23-2005, 12:41 AM
Michael Heiming wrote:
> I'd put all commands without sudo in a script and call this via
> sudo, just make sure your user has no write permissions to the
> dir you put it in.
>
> #!/bin/bash
> # Bring up wireless interface
>
> ifcf="/sbin/ifconfig"
> iwdev="ra0"
> iwcf="/usr/local/sbin/iwconfig"
>
> /sbin/modprobe rt2500
>
> $ifcf $iwdev inet 192.168.3.22 up
>
> $iwcf $iwdev mode Ad-Hoc
> $iwcf $iwdev enc restricted
> $iwcf $iwdev key xxxxxxxxxxxxx
> $iwcf $iwdev ap 00:00:22:22:22:22
> $iwcf $iwdev essid "blah"
> $iwcf $iwdev rate 54M
> # Turn on wireless operation
> $iwcf $iwdev mode 1
>
> ###
>
> Just a quick hack, put together in a few minutes, I'm not using
> wlan serious, just played around with it. The above works just
> fine for my purposes. There's an ipw2200 card in a laptop, found
> the wireless device among the most unstable/crappy devices ever
> used. Probably because of the proprietary firmware, dmesg says
> frequently "ipw2200: Firmware error detected. Restarting." This
> is the moment wireless operation start to suck. Hope your card
> works more reliable?
>
> Good luck
>


Hi Michael,

Thanks for your help, I'll give that a try!

Regards,
Chris
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WZC scripting Thomas K Wireless Internet 0 08-24-2005 06:42 AM
Scripting and the Registry RayRedSoxFan Windows Networking 0 08-22-2005 10:51 PM
tcpdump and scripting Matt Linux Networking 1 05-28-2005 11:50 PM
Scripting configuration entries? Eras Wireless Internet 5 01-21-2005 07:37 PM
Re: Network Scripting Pegasus \(MVP\) Windows Networking 2 08-18-2003 11:02 PM



1 2 3 4 5 6 7 8 9 10 11