PDA

View Full Version : [all variants] Run a command after acquiring a network address via DHCP



leachyboy2001
September 22nd, 2009, 03:14 AM
Long story I want to run some kind of script that would essentially run at start up that would make my computer acquire an IP address THEN run a set command.

I'm terrible at writing scripts but if someone could think of a way to do this please share. I can't seem to find any other posts relating to anything of this sort here or anywhere else.

kevdog
September 22nd, 2009, 03:18 AM
Something like this in a script perhaps:

sudo dhclient wlan0 && <command name or script file>

lswb
September 22nd, 2009, 05:03 AM
There is also provision built in to the dhcp client for automatically running scripts (as root) that may be useful to you. See "man dhclient-script" and look at the HOOKS section.

leachyboy2001
September 22nd, 2009, 02:08 PM
Ahhhh, excellent that is why I ask my questions here, I probably would have never thought of that.