# wpa_supplicant: how to run a script after connection?

## pattie102

Hi community!

While I'm sitting in my boring analysis class in university, I'm just asking myself if there's a solution for this issue: I use my gentoo mainly on my laptop which I connect regularly through WLAN in various networks. At home I use a WPA encrypted net, in university the wireless network is actually unencrypted, but you either need to login on a website you will automatically be redirected to if you want to access a website or you login via cisco vpn-client. So at the moment I do have to connect to vpn manually after I'm connected to the wlan. Now my question:

Is it possible to let wpa_supplicant start a small script or just run the line "vpnclient connect vpn-uniwue" when I'm connected to my university wireless lan (and _ONLY_ to university wlan)?

Thanks for any hints or ideas.

Hantilles,

PS: here is my current wpa_supplicant.conf just to give some information:

```

ctrl_interface=/var/run/wpa_supplicant

fast_reauth=0

update_config=1

#my own net

network={

        ssid="hxxx-WRT54G"

        psk="xxxxxxx"

        key_mgmt=WPA-PSK

        group=TKIP

        priority=5

#       proto=RSN #WPA2 works, but can't be used as other clients @home can't use it...

}

#university wlan

network={

        ssid="RZUW"

        key_mgmt=NONE

        priority=4

}

#.... some friend's nets

```

----------

## UberLord

For wpa_supplicant-0.5.x it uses the script /etc/wpa_supplicant/wpa_cli.sh every time a connection is made/lost - however, an ip address will not have been configured when that is called, so you probably need this in /etc/conf.d/net

```
postup() {

   if [[ ${ESSID} == "RZUW" ]] ; then

      run_your_login_program

   fi

   return 0

}

predown() {

   if [[ ${ESSID} == "RZUW" ]] ; then

      kill_your_login_program

   fi

   return 0

}
```

----------

## pattie102

Thank you, sounds not bad. But there are still two problems: not every time when I reconnect to the wlan I restart the interface (suspend to ram is not unusual) or really want to restart the interface. and the other problem is that the cisco vpnclient init-script depends on a running net. But thanks for pointing me into the right direction. Maybe I can solve this problem now myself...

----------

