Re: How to detect the number of network adapters installed from kickstart file for network config?

Patrick Lists <[email protected]>
Newsgroups gmane.linux.redhat.kickstart.general
Message-ID <[email protected]>
On 02/19/2011 04:09 AM, Patrick Lists wrote:
[snip]
> Here's how I would try to solve it. Totally untested, use at own risk.
> Mind the linewrap. It's all one line. My box has lo, br0, eth0 and
> virbr0 so the script should give a total of 4 interfaces.
>
> $ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk
> 'BEGIN {no_of_interfaces=0} /^[a-z]/ {print $1}' | awk 'END
> {no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}'
>
> Number of interfaces: 4 (correct so apparently this works)

Rereading your question and the script above it greps all interfaces 
while I think you only need the eth interfaces. If that is the case 
change /^[a-z]/ to /^eth/

$ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk 
'BEGIN {no_of_interfaces=0} /^eth/ {print $1}' | awk 'END 
{no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}'

Number of interfaces: 1

Regards,
Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.