Operating System - HP-UX
1826270 Members
3568 Online
109692 Solutions
New Discussion

HPUX 11.0: Collecting Multiple LAN Card Infomation

 
SOLVED
Go to solution
LG Porter
Frequent Advisor

HPUX 11.0: Collecting Multiple LAN Card Infomation

I have several HP servers that contain multiple NIC's configured. I would like to automate the information collection process from the "lanscan" and "ifconfig" commands for each lan card that is configured in each server. That is, if a server has four lan cards (lan0, lan1, lan2, and lan3 shown from the "lanscan" command), how could I automate the "ifconfig" command to collect information for each lan card and pipe the output to a file? Could the lanscan and ifconfig be used in a script to automatically collect information on each lan card and index to the next card?
5 REPLIES 5
James A. Donovan
Honored Contributor
Solution

Re: HPUX 11.0: Collecting Multiple LAN Card Infomation

could probably be done a little more elegantly but...

for card in `lanscan|sed -e '1d' -e '2d'|awk '{print $5}'`;do
ifconfig $card >>laninfo.txt
done

or something along those lines....
Remember, wherever you go, there you are...
Sridhar Bhaskarla
Honored Contributor

Re: HPUX 11.0: Collecting Multiple LAN Card Infomation

Hi,

Attached is a script that I recently wrote. This can be run as a user.
It will create a "|" seperated file called result.nic in the current directory. It can be easily imported into Excel.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Rajeev  Shukla
Honored Contributor

Re: HPUX 11.0: Collecting Multiple LAN Card Infomation

run the followin gcommand

for i in `lanscan|grep lan|awk '{print $5}'`
> do
> ifconfig $i
> done
Ravi_8
Honored Contributor

Re: HPUX 11.0: Collecting Multiple LAN Card Infomation

Hi,
ifconfig is a built in command, you can use this in a shell script.

machine=`uname -a|awk '{print $2}'`
for i in `lanscan|grep -i lan|awk '{print $5}'`
do
echo "Machine name">laninfo
echo "------------">>laninfo
echo $machine >> laninfo
ifconfig $i >> laninfo
done
never give up
BIHAN
Frequent Advisor

Re: HPUX 11.0: Collecting Multiple LAN Card Infomation

hello,
it's not more than the other answer but it's in one line an it gives the speed too

lanscan | awk '/lan/ { printf "echo %s\n ifconfig %s \n lanadmin -x %s\n", $0, $5, $3} ' | sh

you can test it without the "|sh"