You are not logged in.

#1 2010-11-21 22:03:18

Hilariousity
Member
Registered: 2009-06-09
Posts: 20

My bash scripts used to work but now it doesn't

I have this script to startup my wifi that works on my other laptop but doesn't seem to work on the one that I am currently using. It goes like this

#!/bin/bash
ifconfig wlan0 up
echo "these wireless networks have been found in your area"
#return networks within scan range
iwlist wlan0 scan | grep ESSID | sed -e "s/.*ESSID:\"\([^\"]*\).*/\1/"
echo -n "Which network would you like to connect too? "
read SSID
#associate with a wireless gateway then obtain an ip
iwconfig wlan0 essid $SSID
dhcpcd wlan0

To try to figure out what is wrong with my script I tried each command one by one and recieved no errors.....So then I put sleep statements in between the commands and recieved the same errors. I have no idea what to do from this point except post the errors I am getting. Here you go.


: Unknown server error
ifconfig: `--help' gives usage information.
these wireless networks have been found in your area
sed: -e expression #1, char 27: unknown option to `s'

None of these errors make sense to me so I am hoping one of you fine gentlemen can enlighten me as to what is going wrong.

Offline

#2 2010-11-21 22:27:16

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: My bash scripts used to work but now it doesn't

I see no 'sleep' statements above, can you post it all using [ code ] tags https://bbs.archlinux.org/help.php#bbcode ?

Offline

#3 2010-11-21 22:44:23

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: My bash scripts used to work but now it doesn't

I think you don't do this error but just in case.
Is the device wlan0 correct or does it maybe has an other name?

For a better debugging could you use this little modified version and give the output?

#!/bin/bash -x
ifconfig wlan0 up
echo "these wireless networks have been found in your area"
#return networks within scan range
iwlist wlan0 scan | grep ESSID | sed -e 's/.*ESSID:"\([^"]*\).*/\1/'
echo -n "Which network would you like to connect too? "
read SSID
#associate with a wireless gateway then obtain an ip
iwconfig wlan0 essid $SSID
dhcpcd wlan0

I suppose it would be better to post the output of it to something like pastebin because it could be quite a lot.


Website: andrwe.org

Offline

#4 2010-11-21 23:04:20

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: My bash scripts used to work but now it doesn't

i just tested your script and running it from a terminal worked. (i didnt connect to a network cause i dont have an open network but it did find networks in range).

btw, why are you using this instead of netcfg + wifi-select which does this and in a more elegant way

Offline

#5 2010-11-22 00:30:36

Hilariousity
Member
Registered: 2009-06-09
Posts: 20

Re: My bash scripts used to work but now it doesn't

ok heres the output


: Host name lookup failure
ifconfig: `--help' gives usage information.
these wireless networks have been found in your area
wlan0     Interface doesn't support scanning : Network is down

sed: -e expression #1, char 27: unknown option to `s'
yourmometwork would you like to connect too?
': not a valid identifierd: `SSID
dhcpcd[1462]: version 5.2.8 starting
: interface not found or invalid

ok slightly different output. now what?

@eldragon I am not using netcfg because this is the first thing I found that would work when I started using arch. I was a very confused newbie back then, but the script worked until I switched to this laptop.

@karol I removed the sleep statements when they didn't work. I will be sure to use the code tags next time tongue

Offline

#6 2010-11-22 07:53:53

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: My bash scripts used to work but now it doesn't

Here you can see the error:

: Host name lookup failure

All following errors are just caused by this one.

Do you have set your hostname in /etc/hosts like:

127.0.0.1 localhost hostname

Last edited by Andrwe (2010-11-22 07:54:18)


Website: andrwe.org

Offline

Board footer

Powered by FluxBB