|
View Full Version : Detect the value from TypePerf
Kathy 09-14-2006, 01:36 AM 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
foxidrive 09-14-2006, 02:19 AM On 13 Sep 2006 17:36:15 -0700, Kathy wrote:
> 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
Kathy 09-14-2006, 03:52 AM 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).
foxidrive wrote:
> On 13 Sep 2006 17:36:15 -0700, Kathy wrote:
>
> > 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
foxidrive 09-14-2006, 05:18 AM On 13 Sep 2006 19:52:56 -0700, Kathy wrote:
> 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?
> foxidrive wrote:
>
>> On 13 Sep 2006 17:36:15 -0700, Kathy wrote:
>>
>>> 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
billious 09-14-2006, 06:53 AM "Kathy" <kathy_houtami@hotmail.com> wrote in message
news:1158202376.507583.133400@b28g2000cwb.googlegroups.com...
[top-posting moved]
> foxidrive wrote:
>
>> On 13 Sep 2006 17:36:15 -0700, Kathy wrote:
>>
>> > 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).
>
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.
Kathy Houtami 09-14-2006, 11:07 PM 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
billious wrote:
> "Kathy" <kathy_houtami@hotmail.com> wrote in message
> news:1158202376.507583.133400@b28g2000cwb.googlegroups.com...
>
> [top-posting moved]
>
> > foxidrive wrote:
> >
> >> On 13 Sep 2006 17:36:15 -0700, Kathy wrote:
> >>
> >> > 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).
> >
>
> 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.
|
|
|