Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output lscfg

Status
Not open for further replies.

AIXRALF

Technical User
Apr 29, 2002
5
0
0
DE
Hello,

i make a file with lscfg -vp > file.

In the file is this:


rmt11 14-08-01 IBM 3590 Tape Drive and
Medium Changer (FCP)

Manufacturer................IBM
Machine Type and Model......03590H1A
Serial Number...............000000030032
Device Specific.(FW)........F26E
Loadable Microcode Level....A0B00E26


I will a output like this:

rmt11 , 000000030032
rmt10 , xxxx
rmt12 , xxxxx

Any idea?

Thank you

Ralf
 
The following will work for lscfg -v. It does not work if you add the platform specific data (the -p option), since that is output in a hierarchical format.
Code:
lscfg -v |
  tail +7 | # Skip first six lines of output
  egrep "^  [^ ][^ ]*|Serial Number" | # Get only lines with device and Serial
  sed "
s/^  *Serial Number\.\.*\([^.][^.]*$\)/\1=/
s/^  \([^ ][^ ]*\) .*/=\1/
" | # Change Serial Number line to 'XXX=' and device line to '=dev'
  tr "\n=" ",\n" | # Replace newline with ',' and '=' with newline
  sed "/^,$/d" # Remove extra commas
 
For something like this I would recommend using awk.
[tt]
awk '/^rmt/ {printf "%s , ", $1}
/Serial Num/ {print substr($0,35,12)}' file > file2
[/tt]
Seems to work on the example file supplied.
 
Here is a better sample of the output:
Code:
  cd0               10-68-00-3,0      16 Bit SCSI Multimedia CD-ROM Drive
                                      (650 MB)

        Manufacturer................IBM     
        Machine Type and Model......CDRM00203
        ROS Level and ID............1_06
        Device Specific.(Z0)........058002028F000038
        Part Number.................04N2964     
        EC Level....................F73113    
        FRU Number..................97H7796     

  rmt0              10-68-00-5,0      SCSI 4mm Tape Drive (20480 MB)

        Manufacturer................HP      
        Machine Type and Model......IBM-C568303030!D
        Device Specific.(Z1)........C105
        Serial Number...............31167845
        Device Specific.(LI)........A1700292
        Part Number.................19P0798 
        FRU Number..................19P0802     
        EC Level....................H27417    
        Device Specific.(Z0)........0180020283000038
        Device Specific.(Z3)........L1
Part of the problem is that some devices do not have a serial number (i.e. cd0). I know my solution is not optimal, but it takes this into account.
 
something like that:
nawk -f disks.awk disks.txt

#----------- disks.awk
NF > 3 && !match($0, /[.][.]+/) {printf("%s , %s", $1, (!diskFound) ? "\n" : ""
); diskFound=1}
/Serial Num/ {print substr($0,37)}
vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top