On 1/20/11 12:57 PM, Christian Paro wrote:
>
> #!/bin/bash
> ### BEGIN SCRIPT: getswitchname ###
> function getVSwitch {
> local iface=$1
> local userid=$(awk '/^VM00 Name:/{print $3}' /proc/sysinfo)
> local vdev=$(readlink -f /sys/class/net/${iface}/device)
> vdev=${vdev##*.}
> # Get the line after the line containing the appropriate
> # vdev, and pull the vswitch name from the second field
> # following the word "VSWITCH".
> vmcp query virtual nic |
> sed -n '/^Adapter '${vdev}'/{n;p;}' |
> sed -rn 's/.*VSWITCH:\s+\S+\s+(\S*).*/\1/p'
For a very minor variation (I just like working with whole lines), try:
vmcp query v nic | sed 'N;s/\n/ /' | \
awk "/Adapter $vdev/"' {print $12 " " $13}'
That is, use sed to join each pair of lines, then awk to print the 12th
and 13th field of the line matching "Adapter xxxx"
> }
> getVSwitch $1
> ### END OF SCRIPT ###
-- Pat
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/