1

Could you assist me how to retrieve specific lines and put it into CSV file? How to process the output via Bash and Python3?

Remark:

"objectID" represents each found server

"An instance of Path" group could be more than 2 presented there for each server

I will be grateful for little explanation.

Example Command output:

cat /tmp/output.log

  objectID=HSDOMAIN.HM700.212040.9.9
  portID=9
  portName=CL3-C
  domainID=9
  hostMode=Windows Extension
  hostModeOption=7;40;73
  displayName=CL3-C-9
  domainType=0
  nickname=CLSRV129
  resourcePartitionUnitID=0
  List of 10 Path elements:
    An instance of Path
      objectID=PATH.HM700.212040.9.9.12573
      devNum=12,573
      displayDevNum=00:31:1D
      portID=9
      portName=CL3-C
      domainID=9
      scsiID=15
      LUN=3
      wwnSecurityValidity=true
    An instance of Path
      objectID=PATH.HM700.212040.9.9.4413
      devNum=4,413
      displayDevNum=00:11:3D
      portID=9
      portName=CL3-C
      domainID=9
      scsiID=15
      LUN=8
      wwnSecurityValidity=true

CSV file summarized:

cat /tmp/output.csv

212040;CLSRV129;CL3-C;31:1D
212040;CLSRV129;CL3-C;11:3D
  • will An instance of Path and wwnSecurityValidity are static? – Siva Oct 16 '19 at 13:38
  • Regarding "An instance of Path" yes, it's opening new group of data. As you may see it's somehow structured by indentation. Regarding all values inside, it could be different in each entry. To summarize each top "objectID=" opening new host info. Every last "An instance of Path" in ObjectID closing each host details output. But the beginning keyword could be "nickname=" because appear only once for each host. Under host I need to retrieve all connected disks ID: "displayDevNum", "portName" and storage box ID "objectID" only 212040. – Mac Oct 16 '19 at 14:16
0

Using sed and Miller (https://github.com/johnkerl/miller), and running

sed -r 's/(.+object.+)/\n\1/g' input_01.csv | \
mlr --x2c --ips "=" clean-whitespace \
then cut -o -f objectID,nickname,portName,displayDevNum  \
then unsparsify \
then put -S '$objectID=regextract_or_else($objectID,"[0-9]{6}","")' \
then fill-down -f nickname \
then filter -x -S '$displayDevNum==""'

you will have

objectID,nickname,portName,displayDevNum
212040,CLSRV129,CL3-C,00:31:1D
212040,CLSRV129,CL3-C,00:11:3D
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.