- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Extracting useful info from swlist
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2004 10:10 PM
06-17-2004 10:10 PM
I'm basically using...
/usr/sbin/swlist -a os_release -a machine_type -a title @$HOST
...to get information off each host in a for loop. The problem is, I need to extract each field into a variable for processing by the shell. Problem is the output from swlist is whitespace delimited (both spaces and tabs in various formats), and sometimes fields (eg os_release) can be blank.
So, I can't use awk to split based on white-spaces, because some fields shift left if any other fields are blank. I can't use a position-based cut because they appear to be differently spaced on different OS releases.
Question is, what can I do? I can't see that there's an option in swlist to eg give a comma-delimited output, which would be ideal. I can't really think of a way to use awk to figure it out, because either of os_release and machine_type can and sometimes are both blank!
Ideas?
Cheers, Sy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2004 10:31 PM
06-17-2004 10:31 PM
Re: Extracting useful info from swlist
something like
field1=`/usr/sbin/swlist -a os_release | perl -ne '@a=split /\s+/;print "$a[1]\n"'`
This will give you field 1 (change the 1 to a 2 for the second field).
@a should be an array that contains all the fields as different elements and you can print any one you like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2004 11:20 PM
06-17-2004 11:20 PM
Re: Extracting useful info from swlist
100BaseT-01 ?.11.11 * HP-PB 100BaseT;Supptd HW=A3495A;SW=J2759BA
A3495A ?.10.* 9000/[68]?? HP-PB 100BT LAN/9000
A5230A ?.11.00 * 100BT/9000 PCI
FibrChanl-01 ?.11.11 *:*64 PCI-X FibreChannel;Supptd HW=A6826A,A9782A,A9784A
Firmware_Check Checks system firmware
ITOAgent ?.11.* 9000/[78]??:* VPO Agents
Ignite-UX-11-11 HP-UX Installation Utilities for Installing 11.11 Systems
LSOF HPUX 11i LSOF
Probably not easy to see from this, but eg LSOD and Ignite-UX-11-11 have no os_release or machine_types set, so if splitting on white spaces, field 2 would become "HPUX" (from the start of the name field), instead of B.11.11 eg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2004 11:32 PM
06-17-2004 11:32 PM
SolutionIdea:
/usr/sbin/swlist -v -a os_release -a machine_type -a title |
awk '
/^os_release/ {os_release=$2};
/^machine_type/ {machine_type=$2};
/^title/ {sub(/^title */,""); title=$0};
{
if (title != "") {
printf ("%s|%s|%s\n", os_release, machine_type, title);
title="";
}
}'
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2004 01:18 AM
06-18-2004 01:18 AM
Re: Extracting useful info from swlist
/usr/sbin/swlist -v -a tag -a os_release -a machine_type -a title | awk '
/^bundle/ || /^product/ {interesting=1 ; title=""};
/^tag/ {tag=$2};
/^os_release/ {os_release=$2};
/^machine_type/ {machine_type=$2};
/^title/ {sub(/^title */,""); title=$0};
{if(title != "" && interesting == 1) {
printf("%s,%s,%s,%s\n",tag,os_release,machine_type,title);
interesting=0
}
}'
Cheers