I have two things that I need to happen on different events. Firstly when a user logs on it executes a basic command to setup wpa_supplicant if it hasn't been setup already by another user at the moment i have to manually use:
wpa_supplicant -Dmadwifi -iath0 -
I then want it to initiallise wpa_gui so the user can select the network to connect to.

The other problem is that on connection wpa_gui isn't running a dhcp configuration so I have to manually use:
dhclient ath0
Of course the main problem is these need to be run under root aswell. I don't know how to get these to execute on the event, if it is even possible. Can anyone help?