First page Back Continue Last page Summary Graphics
Finding the DHCP address
Classic Unix!
Look in ifconfig output: ifconfig
Pipe to grep: |grep - A 2 "eth0"
Pipe to awk: |awk '/inet/ {print $2}'
Pipe to sed: |sed - e s/addr://
Put it all together and put result in an environmental variable:
IPADDR =" `ifconfig|grep - A 2 "eth0"|awk '/inet/ {print $2}' \ |sed - e s/addr:// ` "
(For reference, output of ifconfig looks like:
eth0 Link encap:Ethernet HWaddr 00:E0:98:05:7B:0F
inet addr:192.168.7.35 Bcast:192.168.7.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
etc )
Notes: