Batch file to Extract Certain Data

Microsoft Windows server 2008 r2 standar...
May 25, 2010 at 06:34:15
Specs: Windows 2008, Core 2 Duo
Hi I would like to create a Batch file which will run some commands and then i want to extract data from the output of the command re-use it as input for next command in same file.



See More: Batch file to Extract Certain Data

Report •


#1
May 29, 2010 at 13:58:40
Hello, please put an example of what exactly you want to do. Extract data from the output you mean saving it to a file and then paste its contents to the console? I hope this is useful anyways:

Code:

SET /p name=Enter your name:

SET newname=%name%


Report •

#2
June 1, 2010 at 11:25:36
Like i run a command

symdg list
i get this output


dgcscr RDF1 Yes 00019010xxxx 34 0 0 0 0
dgdbcluster RDF1 Yes 00019010xxxx 53 0 1 0 0
dgdc RDF1 Yes 00019010xxxx 4 0 0 0 0
dgdhcp RDF1 Yes 00019010xxxx 4 0 0 0 0
dgdns RDF1 Yes 00019010xxxx 12 0 0 0 0
dgeac RDF1 Yes 00019010xxxx 3 0 0 0 0
dgescm RDF1 Yes 00018787xxxx 5 0 0 0 0
dgezfix RDF1 Yes 00019010xxxx 16 0 0 0 0
dgftpu RDF1 Yes 00019010xxxx 6 0 0 0 0
dghadb RDF1 Yes 00018787xxxx 11 0 2 0 0
dghyperion RDF1 Yes 00019010xxxx 34 0 0 0 0
dglicensedesk RDF1 Yes 00019010xxxx 29 0 0 0 0
dgmailpub RDF1 Yes 00019010xxxx 34 0 0 0 0
dgmdbbso RDF1 Yes 00019010xxxx 17 0 0 0 0
dgmdbnsm RDF1 Yes 00019010xxxx 7 0 0 0 0
dgms10 RDF1 Yes 00019010xxxx 5 0 0 0 0
dgms11 RDF1 Yes 00018787xxxx 12 0 0 0 0
dgms12 RDF1 Yes 00018787xxxx 12 0 0 0 0
dgms14 RDF1 Yes 00018787xxxx 12 0 0 0 0

from above i need only first column as input for the next command and it would b like

symrdf query -g dgms12( i want to run this in background and check the output and compare to one of the possible output

o/p:
Device Group (DG) Name : dgname
DG's Type : RDF1
DG's Symmetrix ID : xxxx (Microcode Version: 5874)
Remote Symmetrix ID : xxxx (Microcode Version: 5874)
RDF (RA) Group Number : 2 (01)


Source (R1) View Target (R2) View MODES
-------------------------------- ------------------------ ----- ------------
ST LI ST
Standard A N A
Logical T R1 Inv R2 Inv K T R1 Inv R2 Inv RDF Pair
Device Dev E Tracks Tracks S Dev E Tracks Tracks MDAE STATE
-------------------------------- -- ------------------------ ----- ------------

DEV001 09EE RW 0 0 RW 0757 WD 0 0 A... Consistent
DEV002 09EF RW 0 0 RW 0758 WD 0 0 A... Consistent
DEV003 09F0 RW 0 0 RW 0759 WD 0 0 A... Consistent
DEV004 09F1 RW 0 0 RW 075A WD 0 0 A... Consistent
DEV005 09F2 RW 0 0 RW 075B WD 0 0 A... Consistent
DEV006 09F3 RW 0 0 RW 075C WD 0 0 A... Consistent
DEV007 09F4 RW 0 0 RW 075D WD 0 0 A... Consistent
DEV008 09F5 RW 0 0 RW 075E WD 0 0 A... Consistent
DEV009 09F6 RW 0 0 RW 075F WD 0 0 A... Consistent
DEV010 09F7 RW 0 0 RW 0760 WD 0 0 A... Consistent
DEV011 09F8 RW 0 0 RW 0761 WD 0 0 A... Consistent
DEV012 09F9 RW 0 0 RW 0762 WD 0 0 A... Consistent
DEV013 09FA RW 0 0 RW 0763 WD 0 0 A... Consistent
DEV014 09FD RW 0 0 RW 0764 WD 0 0 A... Consistent
DEV015 09FE RW 0 0 RW 0765 WD 0 0 A... Consistent
DEV016 0A15 RW 0 0 RW 0766 WD 0 0 A... Consistent
DEV017 09EC RW 0 0 RW 0754 WD 0 0 A... Consistent
DEV018 0A02 RW 0 0 RW 0755 WD 0 0 A... Consistent
DEV019 0A13 RW 0 0 RW 0756 WD 0 0 A... Consistent

Total -------- -------- -------- --------
Track(s) 0 0 0 0
MB(s) 0.0 0.0 0.0 0.0

Legend for MODES:

M(ode of Operation) : A = Async, S = Sync, E = Semi-sync, C = Adaptive Copy
D(omino) : X = Enabled, . = Disabled
A(daptive Copy) : D = Disk Mode, W = WP Mode, . = ACp off
(Consistency) E(xempt): X = Enabled, . = Disabled, M = Mixed, - = N/A

here i would only compare across only one column thats state column
whether consistent or not any other (anyother shall throw an error)

if all the inputs from the second command gives the consistent state i should be able to run next file using CALL next commands using the same input from the output of first command of symdg list first column


thanks for the input ..appreciate alot


Report •

#3
June 1, 2010 at 20:39:57
"Hi I would like to create a Batch file which will run some commands and then i want to extract data from the output of the command re-use it as input for next command in same file."

Wo! How many volleys do you guess it would have taken to get the true meaning? @Btdude6 Thanks for helping deconstipate this pipeline!
---
Ahh, much better explanation. (No offense, but the first "shot" was abysmal.) I'm sure this will take several "takes", but I'll "take" a shot.
(why am i such a pun addict? must have been linguistically challenged as an infant)
not tested (i'm too tired tonight). mebbe yull get the idear and debug it on ur own?
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1" %%a in ('symdg list') do (
set xx=0
for /f %%b in ('symrdf query -g %%a' ^| findstr /r "^DEV[0-9][0-9][0-9]" ^| findstr "Consistent$"') do (
if !errorlevel! gtr 0 set xx=1
)
if !xx! equ 0 call test %%a
)


Report •

Related Solutions

#4
June 2, 2010 at 16:42:03
@dude9112 Oh well you didn't give me any example [and you don't have any posting history] so your welcome =p.

I'll leave nbrane to help you with that.


Report •

#5
June 2, 2010 at 16:51:20
@btdude Thanks for the help you tried...
@nbrane awesome....it worked really well....thanks alot

Report •


Ask Question