Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: I need a way to check a txt file for 0 or above..  (Read 5882 times)

0 Members and 1 Guest are viewing this topic.

rmathes

    Topic Starter


    Rookie

    I need a way to check a txt file for 0 or above..
    « on: October 27, 2008, 09:29:05 AM »
    I have a stats file that generated on the hour and it includes the following in it. What I need to do is if the failed reaches above 0 then reset the service that is running this.  I am not sure what the code is to check a certain line in the stat.txt file like row 10  can anyone help with this one?

                    Statistics of (myserver/3300, 11:00:00)
      ----------------------------------------------------------------------------

       Average
      Queue Time     Total       Pending    Executing    Completed   Failed
    ==========================================================================
         0.00              2451            0               0           2439        12

       

    Dias de verano

    • Guest
    Re: I need a way to check a txt file for 0 or above..
    « Reply #1 on: October 27, 2008, 11:19:25 AM »
    what (number) line do you want to check?

    rmathes

      Topic Starter


      Rookie

      Re: I need a way to check a txt file for 0 or above..
      « Reply #2 on: October 27, 2008, 12:34:20 PM »
      Thanks for responding :) I attached the txt file and the line I need to check is under failed.   So if under failed the number is above 0 I need to reset the service.

      [Saving space - attachment deleted by admin]

      Dias de verano

      • Guest
      Re: I need a way to check a txt file for 0 or above..
      « Reply #3 on: October 27, 2008, 12:36:46 PM »
      So it's always the 11th line? (that's what i was asking)

      rmathes

        Topic Starter


        Rookie

        Re: I need a way to check a txt file for 0 or above..
        « Reply #4 on: October 27, 2008, 02:26:09 PM »
        Yes Sir

        Dias de verano

        • Guest
        Re: I need a way to check a txt file for 0 or above..
        « Reply #5 on: October 27, 2008, 03:09:01 PM »
        Code: [Select]
        @echo off

        REM Open stats.txt
        REM skip 10 lines and read 11th line
        REM in 11th line isolate 6th space delimited token
        REM put it in an arithmetic (numerical) variable
        REM check if greater than zero

        for /f "skip=10 tokens=1-6 delims= " %%1 in (stats.txt) do set /a fails=%%6

        echo number of fails: %fails%

        if %fails% GTR 0 goto failure
        goto success

        :failure
        echo failure count greater than zero
        goto next

        :success
        echo failure count equal to zero

        :next


        rmathes

          Topic Starter


          Rookie

          Re: I need a way to check a txt file for 0 or above..
          « Reply #6 on: October 28, 2008, 03:44:54 PM »
          Very nice I tested this out and it works perfect.

          Thank you for your valuable time and help with this.   :)

          Dias de verano

          • Guest
          Re: I need a way to check a txt file for 0 or above..
          « Reply #7 on: October 28, 2008, 04:37:11 PM »
          You are very welcome.