[TriLUG] Scripting question - Debugging help

Roy Vestal rvestal at trilug.org
Fri Sep 29 15:28:36 EDT 2006


I'm writing a script that will be run on every machine that has a 
specific NIC installed. However, I may have more than one. I need to 
setup ifcfg-ethx "automagically" (no touch script). This is for RHEL4U3

Currently, my test machine has 2 identical on board NICs (seen as 
eth0/1) and 2 add on NICs (eth2/3). Manual setup all cards work. This 
script is for the addon cards, not the onboards and detects correctly.

Here's what I have:

#start script

varnum=`grep -i "deviceId: 1234" /etc/sysconfig/hwconf -B7 |grep eth 
|awk {print $2}' | wc -l`

for i in $varname; do
	ethx=`grep -i "deviceId: 1234" /etc/sysconfig/hwconf -B7 |grep eth |awk 
'{print $2}'`
	netconfig -d $ethx --description="Neterion 612" --bootproto=dhcp
done

#end script

It detects the 2 NIC cards and the wc list shows 2. Good. BUT it only 
sets up one ifcfg-ethx.

Deduction:
When the for loop runs, it's either

A: Not seeing both cards, i.e. eth2
B: Not going through both itterations
C: During both itterations, it sees only eth2, never gets to eth3 (what 
I'm thinking is happening).

So, how does one say "ok, you've used this number (i.e. eth2), now look 
for another (eth3).

TIA,
Roy



More information about the TriLUG mailing list