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

Author Topic: just learning  (Read 18963 times)

0 Members and 1 Guest are viewing this topic.

olo131

    Topic Starter


    Rookie

    just learning
    « on: May 25, 2008, 09:47:14 AM »
    I have made a bat file for a speed test I use for work,  I would like to know is there a way to have it copy to a text doc when it finishes automatically.

    Here is my bat file.

    @echo off
    :A
    echo.
    echo CREATED FOR KNOLOGY SPEED TEST        by: OLO 131
    :B
    echo.
    echo Time and Date of Test
    echo.
    Date /t
    Time /t
    echo.
    echo.
    echo Type Number Then Enter
    echo.
    set choice=
    set /p choice=CMTS 
    set /p choice=Port 
    echo.
    echo Iperf Speed Test Server xx.x.xx.xxx
    iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5
    echo.
    echo.
    echo.
    echo.
    echo Ping Iperf Server Test
    ping xx.x.xx.xxx -n 10 -l 64k
    echo.
    echo.
    echo DONE!
    echo.
    pause
    goto B

    .bat_man

    • Guest
    Re: just learning
    « Reply #1 on: May 25, 2008, 10:39:19 AM »
    can u explain more
    what u want it to copy

    olo131

      Topic Starter


      Rookie

      Re: just learning
      « Reply #2 on: May 25, 2008, 10:55:03 AM »
      Yes,
        What I would like is when the test finishes to automatically create a text file named speed test and save on the desktop. I know I can just right click the screen and select all and enter to copy then open notepad then paste it there, I wondered if there was an easier way to automate the process.

      Thank you in advance
      James

      .bat_man

      • Guest
      Re: just learning
      « Reply #3 on: May 25, 2008, 11:25:45 AM »
      its duable but u have to dublicate the commands not all of them ( to insure ur speed check)
      lets assum that the file name is "ur Desktoppath/speed test.txt"
      @echo off
      set fname="ur Desktoppath/speed test.txt"
      :A
      echo.
      echo. >fname
      echo CREATED FOR KNOLOGY SPEED TEST        by: OLO 131
      echo CREATED FOR KNOLOGY SPEED TEST        by: OLO 131 >>fname
      :B
      echo.
      echo. >>fname
      echo Time and Date of Test  >>fname
      echo.
      echo. >>fname
      Date /t
      Date /t >>fname
      Time /t
      Time /t  >>fname
      echo.
      echo. >>fname
      echo.
      echo. >>fname
      echo Type Number Then Enter
      echo Type Number Then Enter >>fname
      echo.
      echo. >>fname
      set choice=
      set /p choice=CMTS 
      echo CMTS>>fname
      echo %choice%>>fname
      set /p choice=Port 
      echo Port>>fname
      echo %choice%>>fname
      echo.
      echo. >>fname
      echo Iperf Speed Test Server xx.x.xx.xxx
      echo Iperf Speed Test Server xx.x.xx.xxx >>fname
      iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5 >>fname //its not douplicated to not change the speed test
      echo.
      echo. >>fname
      echo.
      echo. >>fname
      echo.
      echo. >>fname
      echo.
      echo. >>fname
      echo Ping Iperf Server Test
      echo Ping Iperf Server Test >>fname
      ping xx.x.xx.xxx -n 10 -l 64k >>fname //its not douplicated to not change the speed test
      echo.
      echo. >>fname
      echo.
      echo. >>fname
      echo DONE!
      echo DONE! >>fname
      echo.
      echo. >>fname
      pause
      echo x | pause >>fname
      goto B

      .bat_man

      • Guest
      Re: just learning
      « Reply #4 on: May 25, 2008, 11:29:23 AM »
      oh sorry
      u should put fname between % like that

      echo. >>%fname%

      due to its a variable

      olo131

        Topic Starter


        Rookie

        Re: just learning
        « Reply #5 on: May 25, 2008, 12:09:51 PM »
        First,
           Thank you .bat_man for your help.

          Now I'm getting this error and nothing is in the text file I would think the first couple of lines would copy, and I did add the >>%speed test.txt% in place of >>fname.


        CREATED FOR KNOLOGY SPEED TEST        by: OLO 131


        Sun 05/25/2008
        01:01 PM


        Type Number Then Enter

        CMTS
        Port

        Iperf Speed Test Server xx.x.xx.xxx
        iperf: ignoring extra argument -- and
        iperf: ignoring extra argument -- Settings\James
        iperf: ignoring extra argument -- and
        iperf: ignoring extra argument -- Robyn.DELL-DESKTOP\Desktop


        Here is the code change

        @echo off
        set speed test.txt=C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop
        :A
        echo.
        echo. >%speed test.txt%
        echo CREATED FOR KNOLOGY SPEED TEST        by: OLO 131
        echo CREATED FOR KNOLOGY SPEED TEST        by: OLO 131 >>%speed test.txt%
        :B
        echo.
        echo. >>%speed test.txt%
        echo Time and Date of Test  >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        Date /t
        Date /t >>%speed test.txt%
        Time /t
        Time /t  >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo Type Number Then Enter
        echo Type Number Then Enter >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        set choice=
        set /p choice=CMTS 
        echo CMTS  >>%speed test.txt%
        echo %choice% >>%speed test.txt%
        set /p choice=Port 
        echo Port>>%speed test.txt%
        echo %choice% >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo Iperf Speed Test Server xx.x.xx.xxx
        echo Iperf Speed Test Server xx.x.xx.xxx >>%speed test.txt%
        iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5 >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo Ping Iperf Server Test
        echo Ping Iperf Server Test >>%speed test.txt%
        ping xx.x.xx.xxx -n 10 -l 64k >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        echo DONE!
        echo DONE! >>%speed test.txt%
        echo.
        echo. >>%speed test.txt%
        pause
        echo x | pause >>%speed test.txt%
        goto B
        « Last Edit: April 05, 2009, 09:05:31 PM by olo131 »

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: just learning
        « Reply #6 on: May 25, 2008, 09:20:09 PM »
        he meant for you to use %fname% as a variable that you set when you start the batch, as in
        set fname=speed test.txt

        and then use %fname% as he described, not %speed test.txt%.
        I was trying to dereference Null Pointers before it was cool.

        .bat_man

        • Guest
        Re: just learning
        « Reply #7 on: May 25, 2008, 11:59:17 PM »
        the variable name cant have spaces in its name for that u have to set the variable fname as this example

        set fname="C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop\speed test.txt"

        instead of this
        set speed test.txt=C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop

        i hope it works



        olo131

          Topic Starter


          Rookie

          Re: just learning
          « Reply #8 on: May 26, 2008, 09:08:58 AM »
          .bat_man and BC_Programmer thank you for everything, it works, I have learn a lot form this site and will continue to be a member seeing this is my first.

             Below are the results, now I have another question when the test runs I can not see the results of the speed test or the ping test the command runs in the window just not the result but they do show up in the .txt file. Is there a way to see the test results. IF not I thank you again.

          James

          CREATED FOR KNOLOGY SPEED TEST        by: OLO 131
           
          Time and Date of Test 
           
          Mon 05/26/2008
          09:18 AM
           
           
          Type Number Then Enter
           
          CMTS 

          Port 

           
          Iperf Speed Test Server xx.x.xx.xxx
          ------------------------------------------------------------
          Server listening on TCP port 5001
          TCP window size: 64.0 KByte
          ------------------------------------------------------------
          ------------------------------------------------------------
          Client connecting to xx.x.xx.xxx, TCP port 5001
          TCP window size: 64.0 KByte
          ------------------------------------------------------------
          [1876] local xx.x.xx.xxx port 1247 connected with xx.x.xx.xxx port 5001
          [ ID] Interval       Transfer     Bandwidth
          [1876]  0.0- 0.5 sec  96.0 KBytes  1.57 Mbits/sec
          [1876]  0.5- 1.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  1.0- 1.5 sec  16.0 KBytes   262 Kbits/sec
          [1876]  1.5- 2.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  2.0- 2.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  2.5- 3.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  3.0- 3.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  3.5- 4.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  4.0- 4.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  4.5- 5.0 sec  16.0 KBytes   262 Kbits/sec
          [1876]  5.0- 5.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  5.5- 6.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  6.0- 6.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  6.5- 7.0 sec  16.0 KBytes   262 Kbits/sec
          [1876]  7.0- 7.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  7.5- 8.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  8.0- 8.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  8.5- 9.0 sec  24.0 KBytes   393 Kbits/sec
          [1876]  9.0- 9.5 sec  24.0 KBytes   393 Kbits/sec
          [1876]  9.5-10.0 sec  24.0 KBytes   393 Kbits/sec
          [ ID] Interval       Transfer     Bandwidth
          [1876]  0.0-11.8 sec   536 KBytes   373 Kbits/sec
          [1944] local xx.x.xx.xxx port 5001 connected with xx.x.xx.xxx port 51623
          [ ID] Interval       Transfer     Bandwidth
          [1944]  0.0- 0.5 sec   288 KBytes  4.72 Mbits/sec
          [1944]  0.5- 1.0 sec   362 KBytes  5.93 Mbits/sec
          [1944]  1.0- 1.5 sec   372 KBytes  6.10 Mbits/sec
          [1944]  1.5- 2.0 sec   402 KBytes  6.59 Mbits/sec
          [1944]  2.0- 2.5 sec   379 KBytes  6.21 Mbits/sec
          [1944]  2.5- 3.0 sec   413 KBytes  6.77 Mbits/sec
          [1944]  3.0- 3.5 sec   398 KBytes  6.52 Mbits/sec
          [1944]  3.5- 4.0 sec   385 KBytes  6.31 Mbits/sec
          [1944]  4.0- 4.5 sec   408 KBytes  6.68 Mbits/sec
          [1944]  4.5- 5.0 sec   396 KBytes  6.49 Mbits/sec
          [1944]  5.0- 5.5 sec   408 KBytes  6.68 Mbits/sec
          [1944]  5.5- 6.0 sec   344 KBytes  5.63 Mbits/sec
          [1944]  6.0- 6.5 sec   386 KBytes  6.33 Mbits/sec
          [1944]  6.5- 7.0 sec   394 KBytes  6.45 Mbits/sec
          [1944]  7.0- 7.5 sec   396 KBytes  6.49 Mbits/sec
          [1944]  7.5- 8.0 sec   401 KBytes  6.56 Mbits/sec
          [1944]  8.0- 8.5 sec   405 KBytes  6.63 Mbits/sec
          [1944]  8.5- 9.0 sec   408 KBytes  6.68 Mbits/sec
          [1944]  9.0- 9.5 sec   384 KBytes  6.28 Mbits/sec
          [1944]  9.5-10.0 sec   413 KBytes  6.77 Mbits/sec
          [ ID] Interval       Transfer     Bandwidth
          [1944]  0.0-10.1 sec  7.63 MBytes  6.34 Mbits/sec
           
          Ping Iperf Server Test

          Pinging xx.x.xx.xxx with 64 bytes of data:

          Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=33ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
          Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59

          Ping statistics for xx.x.xx.xxx:

              Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),

          Approximate round trip times in milli-seconds:

              Minimum = 29ms, Maximum = 33ms, Average = 29ms

           
           DONE!

          blastman



            Hopeful

            Re: just learning
            « Reply #9 on: May 26, 2008, 01:04:53 PM »
            you could use 'start C:\path\to\results\text\file.txt' to start the txt file containing the results after the script has run.

            Add it to the end of the batch file, just before your final 'exit'


            hope it helps.



            Blastman, you are the man. Thank You Very Much!!!!!!!!!



            olo131

              Topic Starter


              Rookie

              Re: just learning
              « Reply #10 on: April 05, 2009, 09:02:59 PM »
              Ok I know it's been nearly a year but I have a question with my .bat file

              Using the original command in this post is there any way to have the command restart its self every 15 min once it has been started or to have the command run 4 times in 1 hour.

              Any combo of time will be fine if it can be done

              Thanks
              James

              Reno



                Hopeful
              • Thanked: 32
                Re: just learning
                « Reply #11 on: April 05, 2009, 11:05:25 PM »
                very old thead indeed.

                sleep 15min --- use vbs sleep function
                restart - call the batch itself --- %0
                then to break, press CTRL-C

                Helpmeh



                  Guru

                • Roar.
                • Thanked: 123
                  • Yes
                  • Yes
                • Computer: Specs
                • Experience: Familiar
                • OS: Windows 8
                Re: just learning
                « Reply #12 on: April 06, 2009, 05:55:05 AM »
                Or you could do a scheduled task?

                Also, to do it on different computers without needing to change the code, the path to the desktop (on XP computers) is "%userprofile%\Desktop", can someone check that on a vista computer?
                Where's MagicSpeed?
                Quote from: 'matt'
                He's playing a game called IRL. Great graphics, *censored* gameplay.

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: just learning
                « Reply #13 on: April 06, 2009, 06:08:02 PM »
                can someone check that on a vista computer?

                Works on my Vista Laptop.  :)
                I was trying to dereference Null Pointers before it was cool.

                olo131

                  Topic Starter


                  Rookie

                  Re: just learning
                  « Reply #14 on: April 06, 2009, 07:48:18 PM »
                  Quote
                  very old thead indeed.

                  sleep 15min --- use vbs sleep function
                  restart - call the batch itself --- %0
                  then to break, press CTRL-C


                  Thank you for answering my question and I thought using my old thread was better than starting a new one

                  I sorry I have not learn visual basic I just started with this one command. I'm not looking for someone to just fix my issue just point me in the right direction(and I think you have tried I just don't understand). I don't need a lot of fancy stuff and if I do my command is to simple for that.

                  Thank you  for all your help

                  James