You are not logged in.

#1 05 Jun 2015 13:51

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Looking for help on manipulating cmd output

Hello,
I am trying to get some information from a command output that will need to be run several times on different disk on a storage array.  I don't have any scripting or programing background but have been searching on the interwebs for clues.  So far the only thing I've come up with is | findstr, but that's not working sad.  I could output the cmd to a .txt then copy and paste to a xls, but I have a large amount of disks that I need to run this against.  It would be inefficient and very manual.  So the command and output looks like this:
symdisk show 7a:d15

Symmetrix ID                 : 000192603798
Director                   : DF-7A
Interface                  : D
Target ID                  : 15
Spindle ID                 : 316
External WWN               : N/A
External Array ID          : N/A
External Device Name       : N/A
Disk Group Number          : 3
Disk Group Name            : DG3
Disk Location              : Internal
Technology                 : SATA
Speed (RPM)                : 7200
Form Factor                : 3.5

Disk Blocks                : 3677203922
Block Size                 : 520
Total Disk Capacity (MB)   : 1823565
Free Disk Capacity (MB)    : 132
Rated Disk Capacity (GB)   : 2000
Hyper Size (MB)            : Any
Hyper Count                : 48

Spare Disk                 : False
Spare Coverage             : True
Encapsulated               : False
Disk Service State         : Normal


Hypers (48):
{
#   Vol   Emulation        Dev   Type          Mir Mbr Sts Cap(MB)
--- ----- ---------------- ----- ------------- --- --- --- --------
   1   294 FBA              0048D RAID-6         1   1  RW     37988
   2   295 FBA              00490 RAID-6         1   2  RW     37988
   3   296 FBA              00493 RAID-6         1   3  RW     37988
   4   297 FBA              00496 RAID-6         1   4  RW     37988
   5   298 FBA              00499 RAID-6         1   5  RW     37988
   6   299 FBA              0049C RAID-6         1   6  RW     37988
   7   300 FBA              0049F RAID-6         1   7  RW     37988
   8   301 FBA              004A2 RAID-6         1   8  RW     37988
   9   302 FBA              004A5 RAID-6         1   1  RW     37988
  10   303 FBA              004A8 RAID-6         1   2  RW     37988
  11   304 FBA              004AB RAID-6         1   3  RW     37988
  12   305 FBA              004AE RAID-6         1   4  RW     37988
  13   306 FBA              004B1 RAID-6         1   5  RW     37988
  14   307 FBA              004B4 RAID-6         1   6  RW     37988
  15   308 FBA              004B7 RAID-6         1   7  RW     37988
  16   309 FBA              004BA RAID-6         1   8  RW     37988
  17   310 FBA              004BD RAID-6         1   1  RW     37988
  18   311 FBA              004C0 RAID-6         1   2  RW     37988
  19   312 FBA              004C3 RAID-6         1   3  RW     37988
  20   313 FBA              004C6 RAID-6         1   4  RW     37988
  21   314 FBA              004C9 RAID-6         1   5  RW     37988
  22   315 FBA              004CC RAID-6         1   6  RW     37988
  23   316 FBA              004CF RAID-6         1   7  RW     37988
  24   317 FBA              004D2 RAID-6         1   8  RW     37988
  25   318 FBA              004D5 RAID-6         1   1  RW     37988
  26   319 FBA              004D8 RAID-6         1   2  RW     37988
  27   320 FBA              004DB RAID-6         1   3  RW     37988
  28   321 FBA              004DE RAID-6         1   4  RW     37988
  29   322 FBA              004E1 RAID-6         1   5  RW     37988
  30   323 FBA              004E4 RAID-6         1   6  RW     37988
  31   324 FBA              004E7 RAID-6         1   7  RW     37988
  32   325 FBA              004EA RAID-6         1   8  RW     37988
  33   326 FBA              004ED RAID-6         1   1  RW     37988
  34   327 FBA              004F0 RAID-6         1   2  RW     37988
  35   328 FBA              004F3 RAID-6         1   3  RW     37988
  36   329 FBA              004F6 RAID-6         1   4  RW     37988
  37   330 FBA              004F9 RAID-6         1   5  RW     37988
  38   331 FBA              004FC RAID-6         1   6  RW     37988
  39   332 FBA              004FF RAID-6         1   7  RW     37988
  40   333 FBA              00502 RAID-6         1   8  RW     37988
  41   334 FBA              00505 RAID-6         1   1  RW     37988
  42   335 FBA              00508 RAID-6         1   2  RW     37988
  43   336 FBA              0050B RAID-6         1   3  RW     37988
  44   337 FBA              0050E RAID-6         1   4  RW     37988
  45   338 FBA              00511 RAID-6         1   5  RW     37988
  46   339 FBA              00514 RAID-6         1   6  RW     37988
  47   340 FBA              00517 RAID-6         1   7  RW     37988
  48   341 FBA              0051A RAID-6         1   8  RW     37988
}

My end goal is to have the disk and its hypers in a spreadsheet so that I can create some pivot tables.  Any thoughts on how I can do this would be greatly appreciated.  If I am unclear on anything please let me know.  it's somewhat early here so my brain is still turning on.

Cheers!

Offline

#2 06 Jun 2015 02:06

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

You have shown an example output for your command line, and it can be converted to a comma delimited .CSV file, but you would need to show what information you need to keep from the example above.

Last edited by foxidrive (06 Jun 2015 02:06)

Offline

#3 08 Jun 2015 15:39

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

Hi foxidrive,

thank you for the reply.  Ideally, I would like to learn how I can manipulate the txt, but I know that would take a lot more effort and time on my part to do the research.  To answer your question though, I would like just the information about the Hypers returned.

Hypers (48):
{
#   Vol   Emulation        Dev   Type          Mir Mbr Sts Cap(MB)
--- ----- ---------------- ----- ------------- --- --- --- --------
   1   294 FBA              0048D RAID-6         1   1  RW     37988
...
...
}

Offline

#4 09 Jun 2015 10:56

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

I gather that you are after every line from

Hypers (48):
and down to the next of these characters
}

But how do you want it formatted?  Everything on one entry in the .CSV file?

To teach you how to manipulate that output into another format, we would need to know the original format (which you have shown us) and then the actual format you need it to appear in.

A CSV file could have something like this in it: one line with all data for each output from symdisk show blah

Hypers (48): { all lines here } 
Hypers (53): { all lines here } 
Hypers (21): { all lines here } 
Hypers (18): { all lines here } 

but I am only guessing what style of data you need.

Offline

#5 09 Jun 2015 12:38

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

Ok I understand.  Sorry I am not being clear.

So yea, this is going to go into a xls so .CSV would be preferred.  The output format should look like the table below:

Director    Interface    Target ID    Vol    Dev
DF-7A    D    15    1    0048D
DF-7A    D    15    2    00490
DF-7A    D    15    3    00493
DF-7A    D    15    4    00496
DF-7A    D    15    5    00499
DF-7A    D    15    6    0049C


(NOTE: the table didn't paste well in this forum.  Also, this is a shortened output using data from my original example)

Eventually I would like to be able to return all of the values for the disk, but these should be good for now.

Offline

#6 09 Jun 2015 17:57

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Looking for help on manipulating cmd output

This is a first attempt to try to solve your problem:

@echo off
setlocal EnableDelayedExpansion

rem Create the output file
REM symdisk show 7a:d15 > test.txt

rem Define the list of values to get from the header *with one space at end*.
rem This list is comprised of "name=token#" pairs and must include values
rem *in the same order of the file header*, inserting dummy values if necessary.

set "values=Director=2 Interface=2 TargetID=3 "

rem Process the file and extract the desired values from the header
for /F "skip=1 tokens=1-4 delims=: " %%a in (test.txt) do (

   rem Get this value
   for /F "tokens=1,2* delims== " %%x in ("!values!") do (
      if %%y equ 2 (
         set "%%x=%%b"
      ) else if %%y equ 3 (
         set "%%x=%%c"
      ) else (
         set "%%x=%%d"
      )
      rem Pass to next value
      set "values=%%z"
   )

   rem If no more values: break the loop
   if not defined values goto break1

)
:break1

rem Get the number of lines to skip to reach "Hypers" section
for /F "delims=:" %%a in ('findstr /N "Hypers" test.txt') do set /A skip=%%a+3

rem Process the file and get the Hypers
echo Director,Interface,Target ID,Vol,Dev
for /F "skip=%skip% tokens=1,4" %%a in (test.txt) do (
   if "%%b" equ "" goto break2
   echo %Director%,%Interface%,%TargetID%,%%a,%%b
)
:break2

Previous code may be easily modified in order to get/show more values from the header of the output file. If you want to process several disks this way, show us an example of the disk names.

Antonio

Offline

#7 09 Jun 2015 18:47

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

ohh wow!!!  that is intense...man, no I feel bad.  I thought it would be easier that than.  so does this just go into a .bat?  examples of other disks are:

07c:D17
07d:C17
08d:C18
10b:D17
10d:C18

Offline

#8 10 Jun 2015 18:25

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Looking for help on manipulating cmd output

Well, the most complex part of this program allows you to get additional values from the header by just inserting they in a list! If just a few number of fields were required, the code would be simpler.

Please, confirm that this code works correctly before I try do write the modification for several disks.

Offline

#9 15 Jun 2015 13:12

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

Cool.  Sooo how do I use it?  do I just put it in a .bat file and run it?

EDIT:

I'm assuming yes, so I tried it.

PS C:\Users\mendea1> .\test.bat
The system cannot find the file test.txt.
FINDSTR: Cannot open test.txt
Director,Interface,Target ID,Vol,Dev
tokens=1,4" was unexpected at this time.
PS C:\Users\mendea1>
PS C:\Users\mendea1>

(Created test.txt file then ran it again)

PS C:\Users\mendea1>
PS C:\Users\mendea1> .\test.bat
Director,Interface,Target ID,Vol,Dev
tokens=1,4" was unexpected at this time.

Last edited by vtechdude (15 Jun 2015 21:01)

Offline

#10 16 Jun 2015 13:40

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 205

Re: Looking for help on manipulating cmd output

What happens when you don't run it in the powershell command window?

Offline

#11 16 Jun 2015 19:09

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Looking for help on manipulating cmd output

A couple comments about my answer:

1. You had not shown us how you run symdisk command. The very first two lines in the code (below the usual header) are these:

rem Create the output file
REM symdisk show 7a:d15 > test.txt

This means that you should remove the "REM" part in symdisk command and insert any part that may be needed in order to sucessfully run symdisk (this part is up to you).


2. In order to "Get the number of lines to skip to reach "Hypers" section" I used this command:

for /F "delims=:" %%a in ('findstr /N "Hypers" test.txt') do set /A skip=%%a+3

However, if the word "Hypers" don't appear in test.txt file exactly as written then this command will fail. If "Hypers" may have a different case, then you must insert a /I switch in FINDSTR command this way:

findstr /I /N "Hypers" test.txt

You may check that the command is correct when you execute previous line in the command-line and the right line is displayed..


I tested my program with your example data and it worked correctly; this is a segment of the output:

Director,Interface,Target ID,Vol,Dev
DF-7A,D,15,1,0048D
DF-7A,D,15,2,00490
DF-7A,D,15,3,00493
DF-7A,D,15,4,00496
DF-7A,D,15,5,00499
DF-7A,D,15,6,0049C
DF-7A,D,15,7,0049F
DF-7A,D,15,8,004A2
DF-7A,D,15,9,004A5
DF-7A,D,15,10,004A8

I strongly urge you to do the same thing (run my program with the data you posted here). If you have any further problem, you should check in first place how your posted data differ from the real data!

EDIT: In order to run my code:
- Copy my code into a text file with .bat extension; for example: test.bat
- Open a command-line window (I hope you know how to do this)
- Go to the folder where the Batch file is located: cd "the name/of the/folder"
- Enter the name of the Batch file: test

Last edited by Aacini (16 Jun 2015 19:23)

Offline

#12 17 Jun 2015 19:52

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

Hello,

symdisk show 7a:d15 is the correct syntax for the command.  I followed your instructions and also removed the REM in line 5.  When I run the command I get:

C:\Users\mendea1>test.bat
Director,Interface,Target ID,Vol,Dev
ID,DF-7A,,1,0048D
ID,DF-7A,,2,00490
ID,DF-7A,,3,00493
ID,DF-7A,,4,00496
ID,DF-7A,,5,00499
ID,DF-7A,,6,0049C
ID,DF-7A,,7,0049F
ID,DF-7A,,8,004A2
ID,DF-7A,,9,004A5
...

not sure what I am doing wrong.

Offline

#13 18 Jun 2015 13:04

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

vtechdude wrote:

not sure what I am doing wrong.

I tested Aacini's code and it shows this here with your data -
as you didn't use code tags with your data then perhaps there are tabs or formatting that is lost when you pasted in plain forum text:

Try pasting the data again but use the code button in the menu bar.

DF-7A,D,15,21,004C9
DF-7A,D,15,22,004CC
DF-7A,D,15,23,004CF
DF-7A,D,15,24,004D2
DF-7A,D,15,25,004D5
DF-7A,D,15,26,004D8
DF-7A,D,15,27,004DB
DF-7A,D,15,28,004DE
DF-7A,D,15,29,004E1
DF-7A,D,15,30,004E4
DF-7A,D,15,31,004E7
DF-7A,D,15,32,004EA
DF-7A,D,15,33,004ED
DF-7A,D,15,34,004F0
DF-7A,D,15,35,004F3
DF-7A,D,15,36,004F6
DF-7A,D,15,37,004F9
DF-7A,D,15,38,004FC
DF-7A,D,15,39,004FF
DF-7A,D,15,40,00502
DF-7A,D,15,41,00505
DF-7A,D,15,42,00508
DF-7A,D,15,43,0050B
DF-7A,D,15,44,0050E
DF-7A,D,15,45,00511
DF-7A,D,15,46,00514
DF-7A,D,15,47,00517
DF-7A,D,15,48,0051A

Last edited by foxidrive (18 Jun 2015 13:06)

Offline

#14 18 Jun 2015 13:39

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

That output is what I get in the command prompt after running the program, it doesn't just look like that when I paste it in the forum.  Could it be that formating is being lost when I copy/paste code from forum to notepad?

Offline

#15 19 Jun 2015 00:17

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Looking for help on manipulating cmd output

The same point again: you must run my code with the data you posted here! These are the first three lines of such data:

Symmetrix ID                 : 000192603798
 Director                   : DF-7A
 Interface                  : D

... and these are the last three lines:

  47   340 FBA              00517 RAID-6         1   7  RW     37988
  48   341 FBA              0051A RAID-6         1   8  RW     37988
}

So you must copy precisely that data in the test.txt file! However, if you removed the REM in line 5, then when the program run it runs symdisk command and then the previous test.txt file is lost, right? So, in order to run my code using the same text.txt file that you previously prepared, you must reinsert the REM in line 5!!!

I don't understand why a simple point like this is so difficult to complete... sad It is hard to try to help you when you don't help us!

Antonio

PS - I suggest you to carefully read this post.

Offline

#16 19 Jun 2015 03:29

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

vtechdude wrote:

That output is what I get in the command prompt after running the program, it doesn't just look like that when I paste it in the forum.  Could it be that formating is being lost when I copy/paste code from forum to notepad?

EDIT:

The formatting is lost when you post text TO the forum. You should enclose the text in the CODE tags
which is the right hand icon in the forum editor where you type your reply.

It also uses a monospaced font to display text inside the CODE tags and the CMD prompt uses a monospaced font by default too.

Last edited by foxidrive (19 Jun 2015 03:47)

Offline

#17 22 Jun 2015 22:39

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

Thank you for all of the replies.  I will definitely use the code tags from now on.  Seems like there is some miscommunication somewhere, so let me to describe what I was doing.  From the cmd prompt this is what the cmd and its output looks like:

C:\Users\vtechdude>symdisk show 7a:d15

Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
  Target ID                  : 15
  Spindle ID                 : 316
  External WWN               : N/A
  External Array ID          : N/A
  External Device Name       : N/A
  Disk Group Number          : 3
  Disk Group Name            : DG3
  Disk Location              : Internal
  Technology                 : SATA
  Speed (RPM)                : 7200
  Form Factor                : 3.5

  Vendor ID                  : SATAHGST
  Product ID                 : 722020APCLAR2000
  Product Revision           : JKN7200
  Serial ID                  : B9HSY3UF

  Disk Blocks                : 3677203922
  Block Size                 : 520
  Total Disk Capacity (MB)   : 1823565
  Free Disk Capacity (MB)    : 132
  Rated Disk Capacity (GB)   : 2000
  Hyper Size (MB)            : Any
  Hyper Count                : 48

  Spare Disk                 : False
  Spare Coverage             : True
  Encapsulated               : False
  Disk Service State         : Normal


  Hypers (48):
  {
  #   Vol   Emulation        Dev   Type          Mir Mbr Sts Cap(MB)
  --- ----- ---------------- ----- ------------- --- --- --- --------
    1   294 FBA              0048D RAID-6         1   1  RW     37988
    2   295 FBA              00490 RAID-6         1   2  RW     37988
    3   296 FBA              00493 RAID-6         1   3  RW     37988
    4   297 FBA              00496 RAID-6         1   4  RW     37988
    5   298 FBA              00499 RAID-6         1   5  RW     37988
    6   299 FBA              0049C RAID-6         1   6  RW     37988
    7   300 FBA              0049F RAID-6         1   7  RW     37988
    8   301 FBA              004A2 RAID-6         1   8  RW     37988
    9   302 FBA              004A5 RAID-6         1   1  RW     37988
   10   303 FBA              004A8 RAID-6         1   2  RW     37988
   11   304 FBA              004AB RAID-6         1   3  RW     37988
   12   305 FBA              004AE RAID-6         1   4  RW     37988
   13   306 FBA              004B1 RAID-6         1   5  RW     37988
   14   307 FBA              004B4 RAID-6         1   6  RW     37988
   15   308 FBA              004B7 RAID-6         1   7  RW     37988
   16   309 FBA              004BA RAID-6         1   8  RW     37988
   17   310 FBA              004BD RAID-6         1   1  RW     37988
   18   311 FBA              004C0 RAID-6         1   2  RW     37988
   19   312 FBA              004C3 RAID-6         1   3  RW     37988
   20   313 FBA              004C6 RAID-6         1   4  RW     37988
   21   314 FBA              004C9 RAID-6         1   5  RW     37988
   22   315 FBA              004CC RAID-6         1   6  RW     37988
   23   316 FBA              004CF RAID-6         1   7  RW     37988
   24   317 FBA              004D2 RAID-6         1   8  RW     37988
   25   318 FBA              004D5 RAID-6         1   1  RW     37988
   26   319 FBA              004D8 RAID-6         1   2  RW     37988
   27   320 FBA              004DB RAID-6         1   3  RW     37988
   28   321 FBA              004DE RAID-6         1   4  RW     37988
   29   322 FBA              004E1 RAID-6         1   5  RW     37988
   30   323 FBA              004E4 RAID-6         1   6  RW     37988
   31   324 FBA              004E7 RAID-6         1   7  RW     37988
   32   325 FBA              004EA RAID-6         1   8  RW     37988
   33   326 FBA              004ED RAID-6         1   1  RW     37988
   34   327 FBA              004F0 RAID-6         1   2  RW     37988
   35   328 FBA              004F3 RAID-6         1   3  RW     37988
   36   329 FBA              004F6 RAID-6         1   4  RW     37988
   37   330 FBA              004F9 RAID-6         1   5  RW     37988
   38   331 FBA              004FC RAID-6         1   6  RW     37988
   39   332 FBA              004FF RAID-6         1   7  RW     37988
   40   333 FBA              00502 RAID-6         1   8  RW     37988
   41   334 FBA              00505 RAID-6         1   1  RW     37988
   42   335 FBA              00508 RAID-6         1   2  RW     37988
   43   336 FBA              0050B RAID-6         1   3  RW     37988
   44   337 FBA              0050E RAID-6         1   4  RW     37988
   45   338 FBA              00511 RAID-6         1   5  RW     37988
   46   339 FBA              00514 RAID-6         1   6  RW     37988
   47   340 FBA              00517 RAID-6         1   7  RW     37988
   48   341 FBA              0051A RAID-6         1   8  RW     37988
  }

This is the same output from my original post plus the correct format spacing due to using /code tags.  I took this output and pasted it into a test.txt.  This is what it looks like when it is piped to a file.

Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
  Target ID                  : 15
  Spindle ID                 : 316
  External WWN               : N/A
  External Array ID          : N/A
  External Device Name       : N/A
  Disk Group Number          : 3
  Disk Group Name            : DG3
  Disk Location              : Internal
  Technology                 : SATA
  Speed (RPM)                : 7200
  Form Factor                : 3.5

  Vendor ID                  : SATAHGST
  Product ID                 : 722020APCLAR2000
  Product Revision           : JKN7200
  Serial ID                  : B9HSY3UF        

  Disk Blocks                : 3677203922
  Block Size                 : 520
  Total Disk Capacity (MB)   : 1823565
  Free Disk Capacity (MB)    : 132
  Rated Disk Capacity (GB)   : 2000
  Hyper Size (MB)            : Any
  Hyper Count                : 48

  Spare Disk                 : False
  Spare Coverage             : True
  Encapsulated               : False
  Disk Service State         : Normal


  Hypers (48):
  {
  #   Vol   Emulation        Dev   Type          Mir Mbr Sts Cap(MB) 
  --- ----- ---------------- ----- ------------- --- --- --- --------
    1   294 FBA              0048D RAID-6         1   1  RW     37988
    2   295 FBA              00490 RAID-6         1   2  RW     37988
    3   296 FBA              00493 RAID-6         1   3  RW     37988
    4   297 FBA              00496 RAID-6         1   4  RW     37988
    5   298 FBA              00499 RAID-6         1   5  RW     37988
    6   299 FBA              0049C RAID-6         1   6  RW     37988
    7   300 FBA              0049F RAID-6         1   7  RW     37988
    8   301 FBA              004A2 RAID-6         1   8  RW     37988
    9   302 FBA              004A5 RAID-6         1   1  RW     37988
   10   303 FBA              004A8 RAID-6         1   2  RW     37988
   11   304 FBA              004AB RAID-6         1   3  RW     37988
   12   305 FBA              004AE RAID-6         1   4  RW     37988
   13   306 FBA              004B1 RAID-6         1   5  RW     37988
   14   307 FBA              004B4 RAID-6         1   6  RW     37988
   15   308 FBA              004B7 RAID-6         1   7  RW     37988
   16   309 FBA              004BA RAID-6         1   8  RW     37988
   17   310 FBA              004BD RAID-6         1   1  RW     37988
   18   311 FBA              004C0 RAID-6         1   2  RW     37988
   19   312 FBA              004C3 RAID-6         1   3  RW     37988
   20   313 FBA              004C6 RAID-6         1   4  RW     37988
   21   314 FBA              004C9 RAID-6         1   5  RW     37988
   22   315 FBA              004CC RAID-6         1   6  RW     37988
   23   316 FBA              004CF RAID-6         1   7  RW     37988
   24   317 FBA              004D2 RAID-6         1   8  RW     37988
   25   318 FBA              004D5 RAID-6         1   1  RW     37988
   26   319 FBA              004D8 RAID-6         1   2  RW     37988
   27   320 FBA              004DB RAID-6         1   3  RW     37988
   28   321 FBA              004DE RAID-6         1   4  RW     37988
   29   322 FBA              004E1 RAID-6         1   5  RW     37988
   30   323 FBA              004E4 RAID-6         1   6  RW     37988
   31   324 FBA              004E7 RAID-6         1   7  RW     37988
   32   325 FBA              004EA RAID-6         1   8  RW     37988
   33   326 FBA              004ED RAID-6         1   1  RW     37988
   34   327 FBA              004F0 RAID-6         1   2  RW     37988
   35   328 FBA              004F3 RAID-6         1   3  RW     37988
   36   329 FBA              004F6 RAID-6         1   4  RW     37988
   37   330 FBA              004F9 RAID-6         1   5  RW     37988
   38   331 FBA              004FC RAID-6         1   6  RW     37988
   39   332 FBA              004FF RAID-6         1   7  RW     37988
   40   333 FBA              00502 RAID-6         1   8  RW     37988
   41   334 FBA              00505 RAID-6         1   1  RW     37988
   42   335 FBA              00508 RAID-6         1   2  RW     37988
   43   336 FBA              0050B RAID-6         1   3  RW     37988
   44   337 FBA              0050E RAID-6         1   4  RW     37988
   45   338 FBA              00511 RAID-6         1   5  RW     37988
   46   339 FBA              00514 RAID-6         1   6  RW     37988
   47   340 FBA              00517 RAID-6         1   7  RW     37988
   48   341 FBA              0051A RAID-6         1   8  RW     37988
  }

Then I took the code and pasted that into test.bat.  I left the REM in since the data was already in the .txt file.

@echo off
setlocal EnableDelayedExpansion

rem Create the output file
REM symdisk show 7a:d15 > test.txt

rem Define the list of values to get from the header *with one space at end*.
rem This list is comprised of "name=token#" pairs and must include values
rem *in the same order of the file header*, inserting dummy values if necessary.

set "values=Director=2 Interface=2 TargetID=3 "

rem Process the file and extract the desired values from the header
for /F "skip=1 tokens=1-4 delims=: " %%a in (test.txt) do (

   rem Get this value
   for /F "tokens=1,2* delims== " %%x in ("!values!") do (
      if %%y equ 2 (
         set "%%x=%%b"
      ) else if %%y equ 3 (
         set "%%x=%%c"
      ) else (
         set "%%x=%%d"
      )
      rem Pass to next value
      set "values=%%z"
   )

   rem If no more values: break the loop
   if not defined values goto break1

)
:break1

rem Get the number of lines to skip to reach "Hypers" section
for /F "delims=:" %%a in ('findstr /N "Hypers" test.txt') do set /A skip=%%a+3

rem Process the file and get the Hypers
echo Director,Interface,Target ID,Vol,Dev
for /F "skip=%skip% tokens=1,4" %%a in (test.txt) do (
   if "%%b" equ "" goto break2
   echo %Director%,%Interface%,%TargetID%,%%a,%%b
)
:break2

When I run the .bat i get:

C:\Users\vtechdude>test.bat
Director,Interface,Target ID,Vol,Dev
ID,DF-7A,,1,0048D
ID,DF-7A,,2,00490
ID,DF-7A,,3,00493
ID,DF-7A,,4,00496
ID,DF-7A,,5,00499
ID,DF-7A,,6,0049C
ID,DF-7A,,7,0049F
ID,DF-7A,,8,004A2
ID,DF-7A,,9,004A5
ID,DF-7A,,10,004A8
ID,DF-7A,,11,004AB
ID,DF-7A,,12,004AE
ID,DF-7A,,13,004B1
ID,DF-7A,,14,004B4
ID,DF-7A,,15,004B7
ID,DF-7A,,16,004BA
ID,DF-7A,,17,004BD
ID,DF-7A,,18,004C0
ID,DF-7A,,19,004C3
ID,DF-7A,,20,004C6
ID,DF-7A,,21,004C9
ID,DF-7A,,22,004CC
ID,DF-7A,,23,004CF
ID,DF-7A,,24,004D2
ID,DF-7A,,25,004D5
ID,DF-7A,,26,004D8
ID,DF-7A,,27,004DB
ID,DF-7A,,28,004DE
ID,DF-7A,,29,004E1
ID,DF-7A,,30,004E4
ID,DF-7A,,31,004E7
ID,DF-7A,,32,004EA
ID,DF-7A,,33,004ED
ID,DF-7A,,34,004F0
ID,DF-7A,,35,004F3
ID,DF-7A,,36,004F6
ID,DF-7A,,37,004F9
ID,DF-7A,,38,004FC
ID,DF-7A,,39,004FF
ID,DF-7A,,40,00502
ID,DF-7A,,41,00505
ID,DF-7A,,42,00508
ID,DF-7A,,43,0050B
ID,DF-7A,,44,0050E
ID,DF-7A,,45,00511
ID,DF-7A,,46,00514
ID,DF-7A,,47,00517
ID,DF-7A,,48,0051A
Aacini wrote:

1. You had not shown us how you run symdisk command.

the cmd is just C:\Users\vtechdude>symdisk show 7a:d15

Thank you again everyone!  Hopefully this information helps

Offline

#18 22 Jun 2015 22:57

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 205

Re: Looking for help on manipulating cmd output

Try changing

for /F "tokens=1,2* delims== " %%x in ("!values!") do (

to

for /F "tokens=1,2,3* delims== " %%x in ("!values!") do (

I haven't tested this, but it looks like values is only getting split into two bits instead of three.

Offline

#19 23 Jun 2015 09:44

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

I copy and pasted the items under my result, from your recent post, into a test.txt and z.bat file - and I get this result (end is missing)

Try a different text editor.   Have you tried using notepad, to see if your editor is changing the formatting?


Director,Interface,Target ID,Vol,Dev
DF-7A,D,15,1,0048D
DF-7A,D,15,2,00490
DF-7A,D,15,3,00493
DF-7A,D,15,4,00496
DF-7A,D,15,5,00499
DF-7A,D,15,6,0049C
DF-7A,D,15,7,0049F
DF-7A,D,15,8,004A2
DF-7A,D,15,9,004A5
DF-7A,D,15,10,004A8
DF-7A,D,15,11,004AB
DF-7A,D,15,12,004AE
DF-7A,D,15,13,004B1
DF-7A,D,15,14,004B4
DF-7A,D,15,15,004B7
DF-7A,D,15,16,004BA
DF-7A,D,15,17,004BD
DF-7A,D,15,18,004C0
DF-7A,D,15,19,004C3
DF-7A,D,15,20,004C6
DF-7A,D,15,21,004C9
DF-7A,D,15,22,004CC
DF-7A,D,15,23,004CF
DF-7A,D,15,24,004D2
DF-7A,D,15,25,004D5
DF-7A,D,15,26,004D8
DF-7A,D,15,27,004DB
DF-7A,D,15,28,004DE
DF-7A,D,15,29,004E1
vtechdude wrote:
Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
  Target ID                  : 15
  Spindle ID                 : 316
  External WWN               : N/A
  External Array ID          : N/A
  External Device Name       : N/A
  Disk Group Number          : 3
  Disk Group Name            : DG3
  Disk Location              : Internal
  Technology                 : SATA
  Speed (RPM)                : 7200
  Form Factor                : 3.5

  Vendor ID                  : SATAHGST
  Product ID                 : 722020APCLAR2000
  Product Revision           : JKN7200
  Serial ID                  : B9HSY3UF        

  Disk Blocks                : 3677203922
  Block Size                 : 520
  Total Disk Capacity (MB)   : 1823565
  Free Disk Capacity (MB)    : 132
  Rated Disk Capacity (GB)   : 2000
  Hyper Size (MB)            : Any
  Hyper Count                : 48

  Spare Disk                 : False
  Spare Coverage             : True
  Encapsulated               : False
  Disk Service State         : Normal


  Hypers (48):
  {
  #   Vol   Emulation        Dev   Type          Mir Mbr Sts Cap(MB) 
  --- ----- ---------------- ----- ------------- --- --- --- --------
    1   294 FBA              0048D RAID-6         1   1  RW     37988
    2   295 FBA              00490 RAID-6         1   2  RW     37988
    3   296 FBA              00493 RAID-6         1   3  RW     37988
    4   297 FBA              00496 RAID-6         1   4  RW     37988
    5   298 FBA              00499 RAID-6         1   5  RW     37988
    6   299 FBA              0049C RAID-6         1   6  RW     37988
    7   300 FBA              0049F RAID-6         1   7  RW     37988
    8   301 FBA              004A2 RAID-6         1   8  RW     37988
    9   302 FBA              004A5 RAID-6         1   1  RW     37988
   10   303 FBA              004A8 RAID-6         1   2  RW     37988
   11   304 FBA              004AB RAID-6         1   3  RW     37988
   12   305 FBA              004AE RAID-6         1   4  RW     37988
   13   306 FBA              004B1 RAID-6         1   5  RW     37988
   14   307 FBA              004B4 RAID-6         1   6  RW     37988
   15   308 FBA              004B7 RAID-6         1   7  RW     37988
   16   309 FBA              004BA RAID-6         1   8  RW     37988
   17   310 FBA              004BD RAID-6         1   1  RW     37988
   18   311 FBA              004C0 RAID-6         1   2  RW     37988
   19   312 FBA              004C3 RAID-6         1   3  RW     37988
   20   313 FBA              004C6 RAID-6         1   4  RW     37988
   21   314 FBA              004C9 RAID-6         1   5  RW     37988
   22   315 FBA              004CC RAID-6         1   6  RW     37988
   23   316 FBA              004CF RAID-6         1   7  RW     37988
   24   317 FBA              004D2 RAID-6         1   8  RW     37988
   25   318 FBA              004D5 RAID-6         1   1  RW     37988
   26   319 FBA              004D8 RAID-6         1   2  RW     37988
   27   320 FBA              004DB RAID-6         1   3  RW     37988
   28   321 FBA              004DE RAID-6         1   4  RW     37988
   29   322 FBA              004E1 RAID-6         1   5  RW     37988
   30   323 FBA              004E4 RAID-6         1   6  RW     37988
   31   324 FBA              004E7 RAID-6         1   7  RW     37988
   32   325 FBA              004EA RAID-6         1   8  RW     37988
   33   326 FBA              004ED RAID-6         1   1  RW     37988
   34   327 FBA              004F0 RAID-6         1   2  RW     37988
   35   328 FBA              004F3 RAID-6         1   3  RW     37988
   36   329 FBA              004F6 RAID-6         1   4  RW     37988
   37   330 FBA              004F9 RAID-6         1   5  RW     37988
   38   331 FBA              004FC RAID-6         1   6  RW     37988
   39   332 FBA              004FF RAID-6         1   7  RW     37988
   40   333 FBA              00502 RAID-6         1   8  RW     37988
   41   334 FBA              00505 RAID-6         1   1  RW     37988
   42   335 FBA              00508 RAID-6         1   2  RW     37988
   43   336 FBA              0050B RAID-6         1   3  RW     37988
   44   337 FBA              0050E RAID-6         1   4  RW     37988
   45   338 FBA              00511 RAID-6         1   5  RW     37988
   46   339 FBA              00514 RAID-6         1   6  RW     37988
   47   340 FBA              00517 RAID-6         1   7  RW     37988
   48   341 FBA              0051A RAID-6         1   8  RW     37988
  }

Then I took the code and pasted that into test.bat.  I left the REM in since the data was already in the .txt file.

@echo off
setlocal EnableDelayedExpansion

rem Create the output file
REM symdisk show 7a:d15 > test.txt

rem Define the list of values to get from the header *with one space at end*.
rem This list is comprised of "name=token#" pairs and must include values
rem *in the same order of the file header*, inserting dummy values if necessary.

set "values=Director=2 Interface=2 TargetID=3 "

rem Process the file and extract the desired values from the header
for /F "skip=1 tokens=1-4 delims=: " %%a in (test.txt) do (

   rem Get this value
   for /F "tokens=1,2* delims== " %%x in ("!values!") do (
      if %%y equ 2 (
         set "%%x=%%b"
      ) else if %%y equ 3 (
         set "%%x=%%c"
      ) else (
         set "%%x=%%d"
      )
      rem Pass to next value
      set "values=%%z"
   )

   rem If no more values: break the loop
   if not defined values goto break1

)
:break1

rem Get the number of lines to skip to reach "Hypers" section
for /F "delims=:" %%a in ('findstr /N "Hypers" test.txt') do set /A skip=%%a+3

rem Process the file and get the Hypers
echo Director,Interface,Target ID,Vol,Dev
for /F "skip=%skip% tokens=1,4" %%a in (test.txt) do (
   if "%%b" equ "" goto break2
   echo %Director%,%Interface%,%TargetID%,%%a,%%b
)
:break2

Last edited by foxidrive (23 Jun 2015 09:47)

Offline

#20 23 Jun 2015 14:14

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

I am using notepad.

Offline

#21 24 Jun 2015 13:05

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

What release of Windows are you using?
Do you use a clipboard manager?

I've shown the output here that I get from code you have pasted into the forum - there is a flaw somewhere and it needs to be tracked down.

Offline

#22 24 Jun 2015 15:21

vtechdude
Member
Registered: 04 Jun 2015
Posts: 10

Re: Looking for help on manipulating cmd output

I am on windows 7 enterprise.  i do not have a clipboard manager.  I use firefox for a browser.  I just copy the text from the browser, open up notepad and paste it in.

Offline

#23 24 Jun 2015 15:31

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Looking for help on manipulating cmd output

Try another browser as a test. 
Firefox is what I use here but any addons you have may affect it.

I tested it in Windows XP after my last post and it works there too, and here in Windows 8.1 - both 32 bit.

Last edited by foxidrive (24 Jun 2015 15:32)

Offline

#24 25 Jun 2015 04:14

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Looking for help on manipulating cmd output

Wow, I just can't belive this! Of course, there is a miscommunication somewhere, and it is your insistence on ignore a very simple request!

on 16 Jun 2015 Aacini wrote:

I strongly urge you to do the same thing (run my program with the data you posted here).

on 18 Jun 2015 Aacii wrote:

The same point again: you must run my code with the data you posted here! These are the first three lines of such data:

Symmetrix ID                 : 000192603798
 Director                   : DF-7A
 Interface                  : D

So you must copy precisely that data in the test.txt file!

However, in another post you said:

vtechdude wrote:

This is the same output from my original post plus the correct format spacing due to using /code tags.  I took this output and pasted it into a test.txt.  This is what it looks like when it is piped to a file.

Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
. . .

Well, you just need to carefully watch at two previous listings to realize that they are different! I did NOT asked you to use code tags nor any other adjustment, but just to copy a certain data! There is no way that I (or anyone, like foxidrive) copy-paste this text from your original post and got lines that start with one space, but you (that supposedly did the same thing) got lines that start with 2 spaces! This is true independently of the Windows version, browser or text editor you use. The conclusion is obvious: you still don't run the program with the original posted data! I give up on this matter, so I will not post any further reply to this thread...

--------------------------------------------------------------------------------------------------------------

If some day you finally run the program with the original data and get correct results, and then you run the program with the output from symdisk command and get wrong results again, perhaps at that moment you may wonder: "what is the difference?".

So perhaps you may execute a type command on the file that contains the original data and get something like this:

C:\Users\vtechdude>type test.txt
Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
. . .

... and then you show the output from symdisk command and get this:

C:\Users\vtechdude>symdisk show 7a:d15

Symmetrix ID                 : 000192603798
  Director                   : DF-7A
  Interface                  : D
. . .

... and surely at that point you will think: "the output is the same!". However, if by any chance you show these results to another person that pay attention to the details, then he surely will say: "Of course, you need to skip two lines instead of one!". If after this long explanation you are still confused, then you should read again (or for the first time, if you didn't) the recommendations at the link I gave you:

on 18 Jun 2015 Aacini wrote:

I suggest you to carefully read this post.

... in particular this part:

foxidrive wrote:

Be aware that Batch files are often written around patterns in the data, text and paths\filenames being processed, so the format and layout of the information is important - so ... don't change the layout.

... like deleting a line.

Last edited by Aacini (25 Jun 2015 04:22)

Offline

Board footer

Powered by