I want to run dhcpclient for all the eth* which has no ip
for example
eth0 Link encap:Ethernet HWaddr 00:1E:67:3E:BA:EF
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:d1900000-d1920000
eth1 Link encap:Ethernet HWaddr 00:1B:21:3F:BF:28
inet addr:192.85.1.1 Bcast:192.85.255.255 Mask:255.255.0.0
inet6 addr: fe80::21b:21ff:fe3f:bf28/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:5126 (5.0 KiB)
eth2 Link encap:Ethernet HWaddr 00:1E:67:3E:BA:EE
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:d1920000-d1940000
I want dhclient eth0, dhclient eth2 becasue they have no ip, any help, I haven't a good way to do this, better to use less codes
---------- Post updated at 08:05 AM ---------- Previous update was at 03:55 AM ----------
Any help?
Ygor
4
Try using something like...
$ cat file1
eth0 Link encap:Ethernet HWaddr 00:1E:67:3E:BA:EF
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:d1900000-d1920000
eth1 Link encap:Ethernet HWaddr 00:1B:21:3F:BF:28
inet addr:192.85.1.1 Bcast:192.85.255.255 Mask:255.255.0.0
inet6 addr: fe80::21b:21ff:fe3f:bf28/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:5126 (5.0 KiB)
eth2 Link encap:Ethernet HWaddr 00:1E:67:3E:BA:EE
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:d1920000-d1940000
$ awk '/^eth/{e[++c]=$1}/inet addr/{a[c]=$2}END{for(i=1;i<=c;i++)if(!a)print e}' file1
eth0
eth2
$
Hi thanks for the help, this is the first time I see this awk usage
'/**/***/***/'
Linux what? Ubuntu? Centos? RHEL? Fedora? Arch? Gentoo? SuSe? Other? They share the kernel in common but that doesn't make them the same...
ubuntu, I think it's srcipt's job, so I don't mention more about this :o