Detect the value from TypePerf

  • Thread starter Thread starter Kathy
  • Start date Start date
K

Kathy

Hi,

I'd like to know if there is a way to detect the resulting value from
typeperf command then execute a batch file when the specific condition
is met.

What I'm trying to do is to check when typeperf "Web
Service(_Total)\Anonymous Users/sec" gives the result of 0.000000 then
execute a batch file.

Help???

Cheers
Kathy
 
Hi,

I'd like to know if there is a way to detect the resulting value from
typeperf command then execute a batch file when the specific condition
is met.

What I'm trying to do is to check when typeperf "Web
Service(_Total)\Anonymous Users/sec" gives the result of 0.000000 then
execute a batch file.

Help???

Cheers
Kathy

All on one line - untested.

typeperf "Web Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call batchfile
 
Hi Foxidrive

Thank you for your reply. I tried your suggestion, but it doesnt quite
work.

The result of command look like below:
C:\Documents and Settings\Default User>typeperf "Web
Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call 2.bat
"09/14/2006 14:40:39.953","0.000000"
"09/14/2006 14:40:40.953","0.000000"
"09/14/2006 14:40:41.953","0.000000"
"09/14/2006 14:40:44.953","0.000000"
"09/14/2006 14:40:45.953","0.000000"
"09/14/2006 14:40:46.953","0.000000"
"09/14/2006 14:40:50.046","0.000000"
"09/14/2006 14:40:51.046","0.000000"
"09/14/2006 14:40:52.046","0.000000"
"09/14/2006 14:40:55.046","0.000000"
"09/14/2006 14:40:56.046","0.000000"
"09/14/2006 14:40:57.046","0.000000"

2.bat is a batch files to stop and disabled multiple Services.During
this process the 2.bat never got excuted (none of the listed Services
were stopped and disabled).
 
Hi Foxidrive

Thank you for your reply. I tried your suggestion, but it doesnt quite
work.

The result of command look like below:
C:\Documents and Settings\Default User>typeperf "Web
Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call 2.bat
"09/14/2006 14:40:39.953","0.000000"
"09/14/2006 14:40:40.953","0.000000"
"09/14/2006 14:40:41.953","0.000000"
"09/14/2006 14:40:44.953","0.000000"
"09/14/2006 14:40:45.953","0.000000"
"09/14/2006 14:40:46.953","0.000000"
"09/14/2006 14:40:50.046","0.000000"
"09/14/2006 14:40:51.046","0.000000"
"09/14/2006 14:40:52.046","0.000000"
"09/14/2006 14:40:55.046","0.000000"
"09/14/2006 14:40:56.046","0.000000"
"09/14/2006 14:40:57.046","0.000000"

2.bat is a batch files to stop and disabled multiple Services.During
this process the 2.bat never got excuted (none of the listed Services
were stopped and disabled).

The problem seems to be with 2.bat - Try this line below: there is no
change except you should see "call 2.bat" echoed to the screen where it
would have been launched.

typeperf "Web Service(_Total)\Anonymous Users/sec"|find "0.000000"&&echo call 2.bat

You can remove the screen output from find by including >nul before the &&
but seeing it there proves that it is being detected by FIND and so 2.bat
should be launched. Which OS are you using?
 
[top-posting moved]
Hi Foxidrive

Thank you for your reply. I tried your suggestion, but it doesnt quite
work.

The result of command look like below:
C:\Documents and Settings\Default User>typeperf "Web
Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call 2.bat
"09/14/2006 14:40:39.953","0.000000"
"09/14/2006 14:40:40.953","0.000000"
"09/14/2006 14:40:41.953","0.000000"
"09/14/2006 14:40:44.953","0.000000"
"09/14/2006 14:40:45.953","0.000000"
"09/14/2006 14:40:46.953","0.000000"
"09/14/2006 14:40:50.046","0.000000"
"09/14/2006 14:40:51.046","0.000000"
"09/14/2006 14:40:52.046","0.000000"
"09/14/2006 14:40:55.046","0.000000"
"09/14/2006 14:40:56.046","0.000000"
"09/14/2006 14:40:57.046","0.000000"

2.bat is a batch files to stop and disabled multiple Services.During
this process the 2.bat never got excuted (none of the listed Services
were stopped and disabled).

The issue is that TYPEPERF does not CLOSE the output stream until it
terminates, hence FIND cannot see its input.

Try


typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat

which will exit TYPEPERF after 1 second, executing 2.bat if the output
contains "0.000000"
From there, it's a simple matter of instigating a loop, preferably with some
variety of exit-trigger

[1]:loop
[2]if exist exit-trigger.flag del exit-trigger.flag&goto :eof
[3]typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat
[4]goto loop

4 lines, each labelled [number]
This way, to stop the batch all you need do is create a file called
"exit-trigger.flag" - which can naturally have any name you so desire.
 
Hi billious & foxidrive,

I tried both solutions and the one with the time limit (exit TYPEPERF
after 1 second) works like charmed.

Thank you so much to you both for helping me.

Cheers
Kathy

PS: I'm using Win Server 2003

[top-posting moved]
Hi Foxidrive

Thank you for your reply. I tried your suggestion, but it doesnt quite
work.

The result of command look like below:
C:\Documents and Settings\Default User>typeperf "Web
Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call 2.bat
"09/14/2006 14:40:39.953","0.000000"
"09/14/2006 14:40:40.953","0.000000"
"09/14/2006 14:40:41.953","0.000000"
"09/14/2006 14:40:44.953","0.000000"
"09/14/2006 14:40:45.953","0.000000"
"09/14/2006 14:40:46.953","0.000000"
"09/14/2006 14:40:50.046","0.000000"
"09/14/2006 14:40:51.046","0.000000"
"09/14/2006 14:40:52.046","0.000000"
"09/14/2006 14:40:55.046","0.000000"
"09/14/2006 14:40:56.046","0.000000"
"09/14/2006 14:40:57.046","0.000000"

2.bat is a batch files to stop and disabled multiple Services.During
this process the 2.bat never got excuted (none of the listed Services
were stopped and disabled).

The issue is that TYPEPERF does not CLOSE the output stream until it
terminates, hence FIND cannot see its input.

Try


typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat

which will exit TYPEPERF after 1 second, executing 2.bat if the output
contains "0.000000"
From there, it's a simple matter of instigating a loop, preferably with some
variety of exit-trigger

[1]:loop
[2]if exist exit-trigger.flag del exit-trigger.flag&goto :eof
[3]typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat
[4]goto loop

4 lines, each labelled [number]
This way, to stop the batch all you need do is create a file called
"exit-trigger.flag" - which can naturally have any name you so desire.
 
Back
Top