Why this code don't work?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Why this code don't work?

#1 Post by einstein1969 » 21 Jun 2012 15:27

Hi,

Why this code don't work?

Code: Select all

@echo off

ping -n 2 127.0.0.1 > nul

setlocal enabledelayedexpansion

if "%1" EQU "resto" goto :resto


start "test 1" /LOW cmd /c "typeperf "\Disco fisico(_Total)\%% Tempo disco" "\Processore(_Total)\%% Tempo processore" | %0 resto > %temp%\test1.log"


start "test 2" /LOW cmd /c "typeperf "\Disco fisico(_Total)\%% Tempo disco" "\Processore(_Total)\%% Tempo processore" | FIND  /V "" | %0 resto > %temp%\test2.log"


start "test 3" /LOW cmd /c "typeperf "\Disco fisico(_Total)\%% Tempo disco" "\Processore(_Total)\%% Tempo processore" | findstr  /V "^$" | %0 resto > %temp%\test3.log"


start "test 4" /LOW cmd /c "typeperf "\Disco fisico(_Total)\%% Tempo disco" "\Processore(_Total)\%% Tempo processore" | more +2 | %0 resto > %temp%\test4.log"

echo Wait few second and close the windows "test X" then ...
pause

start notepad %temp%\test1.log
start notepad %temp%\test2.log
start notepad %temp%\test3.log
start notepad %temp%\test4.log

goto :eof

:resto

:loop

   set /p "ln="
   echo [%time%] {%ln%}


goto :loop



Output:
--------------

test 1

Code: Select all


[23.22.30,85] {}
[23.22.30,86] {"(PDH-CSV 4.0)"}
[23.22.30,87] {,"\\PC-XP-MASTER\Disco fisico(_Total)\% Tempo disco"}
[23.22.30,99] {,"\\PC-XP-MASTER\Processore(_Total)\% Tempo processore"}
[23.22.31,99] {,"\\PC-XP-MASTER\Processore(_Total)\% Tempo processore"}
[23.22.31,99] {,"1.120886"}
[23.22.32,00] {,"14.285714"}
[23.22.32,99] {,"14.285714"}
[23.22.32,99] {,"0.053763"}
[23.22.33,00] {,"5.000000"}
[23.22.34,00] {,"5.000000"}
[23.22.34,00] {,"0.056206"}
[23.22.34,01] {,"3.960396"}
[23.22.35,00] {,"3.960396"}
[23.22.35,00] {,"0.325431"}
[23.22.35,01] {,"14.000000"}
[23.22.36,01] {,"14.000000"}
[23.22.36,01] {,"1.615374"}
[23.22.36,01] {,"9.000000"}
[23.22.37,01] {,"9.000000"}
[23.22.37,01] {,"0.193342"}
[23.22.37,04] {,"9.000000"}


test 2

Code: Select all

[23.22.30,85] {}
[23.22.31,99] {"(PDH-CSV 4.0)","\\PC-XP-MASTER\Disco fi}
[23.22.31,99] {sico(_Total)\% Tempo disco","\\PC-XP-MASTER\Processore(_Total)\% Tempo processore"}
[23.22.32,99] {"06/21/2012 23:22:31.994","1.120886","14}
[23.22.32,99] {.285714"}
[23.22.34,00] {"06/21/2012 23:22:32.996","0.053763","5.}
[23.22.34,00] {000000"}
[23.22.35,00] {"06/21/2012 23:22:34.007","0.056206","3.}
[23.22.35,00] {960396"}
[23.22.36,01] {"06/21/2012 23:22:35.009","0.325431","14}
[23.22.36,01] {.000000"}
[23.22.37,01] {"06/21/2012 23:22:36.010","1.615374","9.}
[23.22.37,01] {000000"}


test 3


test 4 Duplicate line

Code: Select all

[23.22.32,99] {"06/21/2012 23:22:31.994","1.120886","14.285714"}
[23.22.32,99] {"06/21/2012 23:22:31.994","1.120886","14.285714"}
[23.22.33,99] {"06/21/2012 23:22:32.996","0.053763","5.000000"}
[23.22.33,99] {"06/21/2012 23:22:32.996","0.053763","5.000000"}
[23.22.34,99] {"06/21/2012 23:22:33.997","0.056768","4.000000"}
[23.22.34,99] {"06/21/2012 23:22:33.997","0.056768","4.000000"}
[23.22.36,00] {"06/21/2012 23:22:34.999","0.325431","14.000000"}
[23.22.36,00] {"06/21/2012 23:22:34.999","0.325431","14.000000"}



?

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Why this code don't work?

#2 Post by Squashman » 21 Jun 2012 15:55

I have never used TYPEPERF so maybe you could explain what you expect your output to be?

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: Why this code don't work?

#3 Post by Fawers » 21 Jun 2012 15:58

What exactly did you want as output?

I'm not acquainted to TYPEPERF, but a brief reading on a website made me wonder what you expected.

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Why this code don't work?

#4 Post by einstein1969 » 21 Jun 2012 16:35

The output i want is the output of typeperf when lanched in a command prompt window

open a windows and type (english language)

Code: Select all

typeperf "\Processor(_Total)\% Processor Time"


The output (mine is italian)

Code: Select all


"(PDH-CSV 4.0)","\\PC-XP-MASTER\processore(_Total)\% Tempo processore"
"06/22/2012 00:30:25.672","21.000000"
"06/22/2012 00:30:26.673","16.000000"
"06/22/2012 00:30:27.685","16.831683"
"06/22/2012 00:30:28.686","15.000000"
"06/22/2012 00:30:29.688","20.000000"
"06/22/2012 00:30:30.689","20.000000"
"06/22/2012 00:30:31.691","13.000000"
"06/22/2012 00:30:32.692","13.000000"
"06/22/2012 00:30:33.704","11.881188"


The first two line don't needed

each second there is a sample of %CPU usage

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: Why this code don't work?

#5 Post by Fawers » 21 Jun 2012 17:01

einstein1969 wrote:The output i want is the output of typeperf when lanched in a command prompt window

We can understand that.
einstein1969 wrote:The first two line don't needed

I'll interpret this as "the first two lines are not needed." Try this from command line:

Code: Select all

for /f "skip=2 delims=" %a in ('typeperf "\Processor(_Total)\% Processor Time"') do @echo %a

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Why this code don't work?

#6 Post by einstein1969 » 21 Jun 2012 17:08

there is no output with

Code: Select all

for /f "skip=2 delims=" %a in ('typeperf "\Processore(_Total)\% Tempo processore"') do @echo %a


is blocked...

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: Why this code don't work?

#7 Post by Fawers » 21 Jun 2012 17:42

Does typeperf need adm privileges?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Why this code don't work?

#8 Post by foxidrive » 21 Jun 2012 22:56

It doesn't work here fawers, either. Dunno why - something to do with the realtime session.


@OP This does work though. What more do you want it to do?

typeperf "\Processor(_Total)\% Processor Time"|more +2 >>file.txt

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Why this code don't work?

#9 Post by einstein1969 » 22 Jun 2012 00:30

foxidrive wrote:It doesn't work here fawers, either. Dunno why - something to do with the realtime session.


@OP This does work though. What more do you want it to do?

typeperf "\Processor(_Total)\% Processor Time"|more +2 >>file.txt


Yes, this work but I have already open a 3D for the resync problem/latency This

I need to work with the result in realtime. When the sample has reached a condition need to execute other control code.

I have found two way , redirect or pipe. I need to decide the better...

Pipe do not have some problem with excessive use of CPU, for resync or for "one sample for time" and/or latency

Post Reply