[TriLUG] Scripting question - Debugging help

Robert Dale robdale at gmail.com
Fri Sep 29 17:42:36 EDT 2006


If you cut-n-pasted the script, the first problem is that I see is that you
declare a variable "varnum" but never use it and second you use a variable
"varname" that's never set.

On 9/29/06, Roy Vestal <rvestal at trilug.org> wrote:
> 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
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>


-- 
Robert Dale



More information about the TriLUG mailing list