You are not logged in.

#1 2008-07-19 06:46:18

Laplace's Daemon
Member
Registered: 2007-08-14
Posts: 30

Bash Scripting: Wait for wireless connection, execute program

I would like to write a script to run at login that would sync the files on my laptop with those on another machine after a wireless connection is established. This needs to work on at least two networks (if I need to supply a network id).   I need this script on my Ubuntu laptop, on which I have Hardy with the default wireless network manager, though I could change if I need to.

I managed to cobble together a fairly inelegant solution:

Q = "0"
while [ $Q = "0" ]; do
   Q=$(ping -c1 www.google.com 2> /dev/null | grep -c google);
done
echo Connected!

Really, though, there has to be a better way to do this!  I looked through some of the iw* functions, but they all seem to return the same things in the "connecting" and "connected" stages.  Any ideas?

Offline

#2 2008-07-19 09:53:13

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Bash Scripting: Wait for wireless connection, execute program


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#3 2008-07-20 11:20:56

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Bash Scripting: Wait for wireless connection, execute program

Using netcfg2 you could just put the command in the POST_UP="" variable, which will be run after a successful connection to the network.

Offline

Board footer

Powered by FluxBB