The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
.
google unix.com



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-05-2007
LinuxRacr LinuxRacr is offline
Registered User
  
 

Join Date: Aug 2007
Location: DFW, Texas
Posts: 60
AWK Help for linkloop

Hello masters of scripting,

I am trying do a small script that will do linkloop tests on interfaces, and I need your help.

Here is a sample output of just a bare lanscan (minus a few interfaces):

lanscan
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
Path Address In# State NamePPA ID Type Support Mjr#
0/5/1/0/4/0 0x001A4BF56734 2 UP lan2 snap2 1 ETHER Yes 119
0/5/1/0/4/1 0x001A4BF56735 3 UP lan3 snap3 2 ETHER Yes 119

I thought I was on to something when I was able to get the following formated output:

# lanscan | grep -v Hardware | grep -v Path | awk '{print $3, $2}'
2 0x001A4BF56734
3 0x001A4BF56735
4 0x001A4BF56736
5 0x001A4BF56737
6 0x001A4BF56394
7 0x001A4BF56395
8 0x001A4BF56396
9 0x001A4BF56397
0 0x001A4B0766B6
1 0x001A4B0766B7

And then I put the output into a for loop, and it falls apart:


for i in `lanscan | grep -v Hardware | grep -v Path | awk '{print $3, $2}'`
do
echo linkloop -i $i
done
linkloop -i 2
linkloop -i 0x001A4BF56734
linkloop -i 3
linkloop -i 0x001A4BF56735
linkloop -i 4
linkloop -i 0x001A4BF56736
linkloop -i 5
linkloop -i 0x001A4BF56737
linkloop -i 6
linkloop -i 0x001A4BF56394
linkloop -i 7
linkloop -i 0x001A4BF56395
linkloop -i 8
linkloop -i 0x001A4BF56396
linkloop -i 9
linkloop -i 0x001A4BF56397
linkloop -i 0
linkloop -i 0x001A4B0766B6
linkloop -i 1
linkloop -i 0x001A4B0766B7

Please help!!
  #2 (permalink)  
Old 12-05-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Not sure what the desired 'linkloop' line supposed to be, but....
Code:
lanscan |nawk '/^[0-9]/ { printf("echo linkloop -i %s %s\n", $3, $2) }' | sh
  #3 (permalink)  
Old 12-05-2007
LinuxRacr LinuxRacr is offline
Registered User
  
 

Join Date: Aug 2007
Location: DFW, Texas
Posts: 60
Got this option as well:


lanscan | awk '/[0-9]/{print $3, $2}' | while read i
do
echo linkloop -i $i
echo "----------------------"
linkloop -i $i
echo
done
  #4 (permalink)  
Old 12-05-2007
LinuxRacr LinuxRacr is offline
Registered User
  
 

Join Date: Aug 2007
Location: DFW, Texas
Posts: 60
Final Solution:

lanscan | awk '/[0-9]/{print $3, $2}' | while read i
do
echo LAN `echo $i | awk '{print $1}'`
echo linkloop -i $i
echo "----------------------"
linkloop -i $i
echo
done

Output:

LAN 0
linkloop -i 0 0x00306E13F682
----------------------
Link connectivity to LAN station: 0x00306E13F682
error: expected primitive 0x30, got DL_ERROR_ACK
dl_error_primitive = 0x2d
dl_errno = 0x04
dl_unix_errno = 57
error - did not receive data part of message

LAN 2
linkloop -i 2 0x00306E0C541F
----------------------
Link connectivity to LAN station: 0x00306E0C541F
-- OK

LAN 3
linkloop -i 3 0x00306E38D363
----------------------
Link connectivity to LAN station: 0x00306E38D363
-- OK

LAN 1
linkloop -i 1 0x00306E21D5B7
----------------------
Link connectivity to LAN station: 0x00306E21D5B7
-- OK
  #5 (permalink)  
Old 12-05-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
lanscan | awk '/[0-9]/{print $3, $2}' | while read lan station
do
   echo LAN "${lan}"
   echo linkloop -i "${lan}" "${station}" 
   echo "----------------------"
   linkloop -i "${lan}" "${station}" 
   echo
done
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0