SUMMARY: OT: Awk script specific to Solaris Box

From: UmanS <kedaran0504_at_yahoo.com.au>
Date: Mon Jan 27 2003 - 23:26:37 EST
Hi Managers,

Thanks for the replies. I have followed Brenden
Gregg's advise not to use awk and make it simple (as
his email). His script covers multiple NIC cards and I
have inserted grep command to skip the virtual IPs.

Thanks to Brenden.

My script ended like this:

display_nic_parameter() {
###Nic parameters in Main ####
for nic in `netstat -i | grep -v ":[0-9]" | awk 'NR >=
3 { if ($1) print $1 }'`
do
    set -- `echo $nic | sed 's/\([0-9]*\)$/ \1/`
    type=$1
    num=$2
    echo "<h5>Interface Name: $nic </h5>"
    /usr/sbin/ndd -set /dev/$type instance $num
    for param in $nicparams
    do
      echo "  $param: \c"
      ndd -get /dev/$type $param
    done
done
}

 
Note: forwarded message attached. 

http://movies.yahoo.com.au - Yahoo! Movies
- What's on at your local cinema?
X-Apparently-To: kedaran0504@yahoo.com.au via 216.136.129.108; 23 Jan
  2003 21:40:09 -0800 (PST)
X-Track: 1: 100
Return-Path: <brendan@sun.com>
Received: from 192.18.42.14  (EHLO nwkea-mail-2.sun.com) (192.18.42.14)
  by mta127.mail.scd.yahoo.com with SMTP; 23 Jan 2003 21:40:09 -0800
  (PST)
Received: from tolstoy-mail1.Aus.Sun.COM ([129.158.178.163]) by
  nwkea-mail-2.sun.com (8.9.3+Sun/8.9.3) with ESMTP id VAA04486 for
  <kedaran0504@yahoo.com.au>; Thu, 23 Jan 2003 21:40:07 -0800 (PST)
Received: from tilly (tilly [129.158.178.26]) by
  tolstoy-mail1.Aus.Sun.COM (8.11.6+Sun/8.11.6/ENSMAIL,v2.1p1) with
  ESMTP id h0O5e1o19271 for <kedaran0504@yahoo.com.au>; Fri, 24 Jan 2003
  16:40:01 +1100 (EST)
Date: Fri, 24 Jan 2003 16:33:22 +1100 (EST)
From: Brendan Gregg <brendan@sun.com>
X-Sender: bg129948@tilly
To: =?iso-8859-1?q?UmanS?= <kedaran0504@yahoo.com.au>
Subject: Re: OT: Awk script specific to Solaris Box
In-Reply-To: <20030124045533.8743.qmail@web9405.mail.yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Length: 2086
X-Converted-To-Plain-Text: from MULTIPART/MIXED by demime 0.99c.7
X-Converted-To-Plain-Text: Alternative section used was text/plain

Hi Uman,

I've attached a script, perhaps this helps?

Sending variables into an awk script is indeed difficult! My solution was
to try a different approach...

no worries,

Brendan


Standard Disclaimer: "Any opinions expressed are personal, 
and do not necessarily reflect those of Sun Microsystems."

Brendan Gregg { 
   Brendan@Sun.COM            # Level 3, 33 Berry St
   Solaris Instructor         # North Sydney, Australia
   Sun Educational Services   # +61 2 9466 9662 (x59662)
}

On Fri, 24 Jan 2003, [iso-8859-1] UmanS wrote:

|Hi gurus,
|
|I have a script like this ( specific to Solaris box)
|
|$$$$$$ Script starts here $$$$$$$$$$$$$$$$$$$
|#!/usr/bin/ksh
|drvparams="transceiver_inuse \
|        link_status \
|        link_speed \
|        link_mode \
|        ipg1 \
|        ipg2 \
|        use_int_xcvr \
|        pace_size \
|        adv_autoneg_cap \
|        adv_100T4_cap \
|        adv_100fdx_cap \
|        adv_100hdx_cap \
|        adv_10fdx_cap \
|        adv_10hdx_cap \
|        autoneg_cap \
|        100T4_cap \
|        100fdx_cap \
|        100hdx_cap \
|        10fdx_cap \
|        10hdx_cap \
|        lp_autoneg_cap \
|        lp_100T4_cap \
|        lp_100fdx_cap \
|        lp_100hdx_cap \
|        lp_10fdx_cap \
|        lp_10hdx_cap \
|        instance \
|        lance_mode \
|        ipg0"
|netstat -i |sed -n '3,$p'|sed -e '/^$/d'|grep -v
|":[0-9]" |nawk
|'{print substr($1,1,3),substr($1,4,1)}' |\
|nawk ' {print "Card Name: " $1, "Instance: " $2}
|    system ("/usr/sbin/ndd -set /dev/"$1 " instance "
|$2)
|    for (parm in $drvparams)
|{
|    print ($parm, " = ", system("/usr/sbin/ndd  /dev/"
|$1 "/" $parm))
|}'
|$$$$$$ Script ends here $$$$$$$$$$$$$$$$$$$$
|
|In this script (please forgive me for using two nawks
|and two seds ) the for loop
|inside nawk
|How can I pass the values from drvparams to the nwak.
|I do not want to
|put it in a separate file.
|
|Thanks again
|Uman
|
|
|http://movies.yahoo.com.au - Yahoo! Movies
|- What's on at your local cinema?
|_______________________________________________
|sunmanagers mailing list
|sunmanagers@sunmanagers.org
|http://www.sunmanagers.org/mailman/listinfo/sunmanagers
|

Brendan Gregg { 
   Brendan@Sun.COM            # Level 3, 33 Berry St
   Solaris Instructor         # North Sydney, Australia
   Sun Educational Services   # +61 2 9466 9662 (x59662)
}

[demime 0.99c.7 removed a section which didn't have a content-type header]
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Mon Jan 27 23:30:03 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:02 EST