LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-23-2006, 04:18 PM   #1
mattydee
Member
 
Registered: Dec 2006
Location: Vancouver, BC
Distribution: Debian,Ubuntu,Slackware
Posts: 479

Rep: Reputation: 48
Script Problem


Hi all,

I wrote the following script to reset the connection to my home router.

Code:
wpa_cli terminate
ifconfig wlan0 up
wpa_supplicant -Dndiswrapper -iwlan0 -c/etc/wpa_supplicant.conf &
sleep 3
dhcpcd wlan0
echo "done"
Everything is fine, except it never manages to get a new dhcp assigned IP. If I open up a console, "dhcpcd wlan0" works just fine.

Any ideas as to why it doesn't work in the script?
 
Old 12-23-2006, 09:09 PM   #2
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Rep: Reputation: 63
i think you have to put the full patch of '/sbin/dhcpcd' in their.
 
Old 12-23-2006, 09:33 PM   #3
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Increase sleep time.

Or, remove & from the end of wpa_supplicant line.
 
Old 12-24-2006, 02:10 AM   #4
mattydee
Member
 
Registered: Dec 2006
Location: Vancouver, BC
Distribution: Debian,Ubuntu,Slackware
Posts: 479

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by kotnik
Increase sleep time.

Or, remove & from the end of wpa_supplicant line.
Thanks
It seems obvious now that the dhcpcd command is executing before the wpa_supplicant has finished authenticating.

However, I must have the & there, or else it won't proceed to the next command.

I will try increasing sleep to 10. I'll post back...

Thanks guys!
 
Old 12-24-2006, 05:47 AM   #5
KleB
Member
 
Registered: Jan 2006
Location: Slovenia
Distribution: Slackware, Gentoo
Posts: 97

Rep: Reputation: 15
How about greping the output of wpa_supplicant for the line which says that it succesfully associated to the network, then write "OK" into a tempfile ... and then continuously probe if the file already has "OK" in it ... if yes then run dhcpcd?
 
Old 12-24-2006, 06:12 AM   #6
KleB
Member
 
Registered: Jan 2006
Location: Slovenia
Distribution: Slackware, Gentoo
Posts: 97

Rep: Reputation: 15
I thought something like this:

Code:
#!/bin/bash

wpa_supplicant |grep "a_string" |sed "s/^.*a_string.*$/OK/" >/tmp/a_temp_file &

while true; do
 if [ `cat /tmp/a_temp_file` = "OK" ]; then
  dhcpcd eth2;
  break;
 fi
done
I haven't tried this, possibly some mistakes (I'm not an bash expert and don't have wpa_supplicant on this machine), you also have to change the obvious bits of code accordingly.
I think it should work, despite being an ugly hack...
 
Old 12-24-2006, 09:20 PM   #7
mattydee
Member
 
Registered: Dec 2006
Location: Vancouver, BC
Distribution: Debian,Ubuntu,Slackware
Posts: 479

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by KleB
I thought something like this:

Code:
#!/bin/bash

wpa_supplicant |grep "a_string" |sed "s/^.*a_string.*$/OK/" >/tmp/a_temp_file &

while true; do
 if [ `cat /tmp/a_temp_file` = "OK" ]; then
  dhcpcd eth2;
  break;
 fi
done
I haven't tried this, possibly some mistakes (I'm not an bash expert and don't have wpa_supplicant on this machine), you also have to change the obvious bits of code accordingly.
I think it should work, despite being an ugly hack...
Hmm... looks like it would work. I've decided to make my life less complicated and use the wpa_gui. It seems to be working well for now. Thanks for your suggestion though.

If this helps anybody:

At first, I didn't realize that you had to give permissions for users to be able to use wpa_gui. I thought that wpa_gui just wasn't working for me.

Once I modified the /etc/wpa_supplicant.conf file to allow users in the "net" group to have access, then all users that I have put in "net" are able to use wpa_gui.

Code:
control_interface_group=net
 
  


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
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
PPPD Script problem when cron-scheduling the script andresurzagasti Linux - Networking 0 11-24-2004 02:54 PM
Script file problem (or operator problem) HELP! lostone Programming 2 05-23-2001 02:30 PM
Script file problem (or operator problem) HELP! lostone Linux - General 1 05-17-2001 06:11 PM
Script file problem (or operator problem) HELP! lostone Linux - Newbie 0 05-15-2001 07:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:56 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