Page 1 of 1

manipulate data from table

Posted: 06 Nov 2013 10:21
by mor.bas
Hi,
I have a abtch that doing process with cluster.
I need to get date from table like:
I run the command :
cluster res "ABC" /stat
and get the output:

Code: Select all

Listing status for resource 'ABC':

Resource             Group                Node            Status
-------------------- -------------------- --------------- ------
ABC                  PHX00483             try00481        Online

I need to print to file the node name (try00481)

And also like this I run the command:
cluster node
and get the output:

Code: Select all

Listing status for all available nodes:

Node           Node ID Status
-------------- ------- --------------------
try00481             1 Up
try00481            2 Up

I need to print to the file the 2 nodes (try00481,try00481)
Thanks in advance...

EDIT aGerman: Code Tags

Re: manipulate data from table

Posted: 06 Nov 2013 13:00
by aGerman
You should use [code][/code] BBCode-Tags for your output to let us know how it is formatted. What are the delimiters of the data fields? Spaces or Tabs? (Redirect the output into a file to figure it out.)

Regards
aGerman

Re: manipulate data from table

Posted: 06 Nov 2013 13:23
by mor.bas
Here I put the output of the command-line more clearrly (I dont' know the bbcode....)

Resource Group Node Status
---------- --------- -------------------- ---------------
ABC PHX00483 try00481 Online


Node Node ID Status
-------------- ------- --------------------
try00481 1 Up
try00481 2 Up

I need to print to a file the data under the node colume...

Re: manipulate data from table

Posted: 06 Nov 2013 13:33
by mor.bas
oh I saw ont the web the bbcode ...
<table>
<tbody>
<tr>
<th>Resource</th>
<th>group</th>
<th>Node</th>
<th>status</th>
</tr>
<tr>
<td>ABC</td>
<td>PHX00483</td>
<td>try00481</td>
<td>Online</td>
</tr>

And the second table....
<table>
<tbody>
<tr>
<th>Node</th>
<th>ID</th>
<th>status</th>
</tr>
<tr>
<td>try00481</td>
<td>1</td>
<td>up</td>
</tr>
<tr>
<td>try00480</td>
<td>2</td>
<td>up</td>
</tr>

Re: manipulate data from table

Posted: 06 Nov 2013 14:40
by aGerman
I edited your initial post (click on the Edit button top right to see what I did).

What I would like to know is what are the delimiters between the data fields.
See my privious reply.

Regards
aGerman

Re: manipulate data from table

Posted: 06 Nov 2013 15:04
by mor.bas
Hi,
Like you edit the first one.
There is only one space between -----.
And the data below the ---- is aligned to the title.
Thanks....

Re: manipulate data from table

Posted: 06 Nov 2013 15:25
by aGerman
Hmm, I hoped it would be tabs. Now these lines wouldn't work if there are spaces in the data fields. Try:

Code: Select all

>"out1.txt" (
  for /f "skip=3 tokens=3" %%i in ('cluster res "ABC" /stat') do echo %%i
)

>"out2.txt" (
  for /f "skip=3" %%i in ('cluster node') do echo %%i
)

Regards
aGerman

Re: manipulate data from table

Posted: 07 Nov 2013 01:21
by mor.bas
Hi,
Can you explain in deeply all the issue of skip and token here?
Thanks,
Eran