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

Author Topic: how can i stop batch/cmd from erasing old lines?  (Read 12356 times)

0 Members and 1 Guest are viewing this topic.

Ädamas

    Topic Starter


    Beginner

    Thanked: 1
    how can i stop batch/cmd from erasing old lines?
    « on: May 14, 2009, 01:16:05 AM »
    how can i stop batch/cmd from erasing old lines?
    i have a command line utility that runs a simulation and Evey 1000 steps it displays the stats of the simulation however the sim can run for a long time (a day or more if i want to) is there any way of stopping command prompt from erazing old things and if this can't be done how can i save to a .txt everything it writes.

    more about the batch file i am using is here http://www.computerhope.com/forum/index.php/topic,83182.0.html
    you're just jealous because the voices talk to me, and not you.

    Reno



      Hopeful
    • Thanked: 32
      Re: how can i stop batch/cmd from erasing old lines?
      « Reply #1 on: May 16, 2009, 02:33:39 AM »
      adamas, if you intent to save a log to txt file:

      example:
      program.exe>log.txt 
      (this will create or overwrite existing log.txt everytime program run)
      program.exe>>log.txt   
      (this will append program.exe screen output to the end of existinglog.txt)

      Ädamas

        Topic Starter


        Beginner

        Thanked: 1
        Re: how can i stop batch/cmd from erasing old lines?
        « Reply #2 on: May 17, 2009, 02:12:32 AM »
        i am not sure what i need to do with that, but it does not sound like what i want
        i would like to save all of the text in this image to a .txt or pervent the cmd from erasing old lines (the list of info can git very long)



        [attachment deleted by admin]
        you're just jealous because the voices talk to me, and not you.

        Dias de verano

        • Guest
        Re: how can i stop batch/cmd from erasing old lines?
        « Reply #3 on: May 17, 2009, 04:55:10 AM »
        pervent the cmd from erasing old lines (the list of info can git very long)

        Sounds like you need to set the command window screen buffer height to a larger number of lines.

        Batcher



          Rookie

          Thanked: 5
          Re: how can i stop batch/cmd from erasing old lines?
          « Reply #4 on: May 17, 2009, 08:10:34 AM »
          Quote
          how can i save to a .txt everything it writes.

          Code: [Select]
          YourBatch.bat>a.txt

          Ädamas

            Topic Starter


            Beginner

            Thanked: 1
            Re: how can i stop batch/cmd from erasing old lines?
            « Reply #5 on: May 19, 2009, 01:03:49 AM »
            it only saves the first line not all of it. ???
            you're just jealous because the voices talk to me, and not you.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: how can i stop batch/cmd from erasing old lines?
            « Reply #6 on: May 19, 2009, 04:49:28 PM »
            it only saves the first line not all of it. ???
            Type YourBatch.bat>a.txt
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            Ädamas

              Topic Starter


              Beginner

              Thanked: 1
              Re: how can i stop batch/cmd from erasing old lines?
              « Reply #7 on: May 20, 2009, 12:16:10 AM »
              i tried it that way and it still only saves the first line
              here is the batch file it is called evolve_b.bat
              Code: [Select]
              @echo off & setlocal & set c=n
              title evolve_b

              if not exist save.txt goto skip
              :setup
              set c=&set/p c=do you want to start from where you left off [y\n] :
              echo.%c%|findstr/ix "y n yes no">nul || goto:setup

              :skip
              if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a
              if /i %c:~,1%.==n. (
              set/p var_time=time :
              set/p var_in=input :
              )
              set/p var_out=output :

              :validateYesNo
              echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve
              set c=&set/p c=are the time,input and output correct [y/n] :
              echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo

              if /i %c:~,1%.==n. goto:setup
               >save.txt echo var_time=%var_time%
              >>save.txt echo var_in=%var_out%
              cd C:\Program Files\Evolve
              evolve_batch
              evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve
              evolve_b.bat>%var_in% %var_out% %var_time%.txt

              you're just jealous because the voices talk to me, and not you.

              Dias de verano

              • Guest
              Re: how can i stop batch/cmd from erasing old lines?
              « Reply #8 on: May 20, 2009, 12:18:15 AM »
              If you echo everything to a file by using the batch name and > the result is that you will see nothing on the screen and it will halt at the first set /p command

              Ädamas

                Topic Starter


                Beginner

                Thanked: 1
                Re: how can i stop batch/cmd from erasing old lines?
                « Reply #9 on: May 20, 2009, 12:30:08 AM »
                If you echo everything to a file by using the batch name and > the result is that you will see nothing on the screen and it will halt at the first set /p command

                how do i remedy that?
                you're just jealous because the voices talk to me, and not you.

                Dias de verano

                • Guest
                Re: how can i stop batch/cmd from erasing old lines?
                « Reply #10 on: May 20, 2009, 12:44:39 AM »
                You seem to know a lot about batch coding from the file you have posted. But you don't know about redirection. ??? Also...

                Code: [Select]
                cd C:\Program Files\Evolve
                Try to remember that thing about paths with spaces!

                I see something strange. That batch file is called evolve_b.bat, and in the code you posted, the last line runs... evolve_b.bat! Have you thought through the implications of this?




                Ädamas

                  Topic Starter


                  Beginner

                  Thanked: 1
                  Re: how can i stop batch/cmd from erasing old lines?
                  « Reply #11 on: May 20, 2009, 01:24:50 AM »
                  the others that had posted toled me to put
                  Code: [Select]
                  YourBatch.bat>a.txt
                  so i put
                  Code: [Select]
                  ...
                  evolve_b.bat>%var_in% %var_out% %var_time%.txt
                  and i didn't make this batch, read this carefully http://www.computerhope.com/forum/index.php/topic,83182.0.html
                  and what is it about paths with spaces?

                  you're just jealous because the voices talk to me, and not you.

                  Reno



                    Hopeful
                  • Thanked: 32
                    Re: how can i stop batch/cmd from erasing old lines?
                    « Reply #12 on: May 20, 2009, 06:39:40 AM »
                    now that's the trouble. the code has set/p which wait for user input, and the output of evolvebatch seems to be real-time.

                    couple of solutions i can think off:
                    1. - double up every echo statement and set/p string, eg. "echo blablabla 1>&2"
                        - save output of evolve_batch to temp.txt eg. "evolve_batch>temp.txt",
                        - then when finish running, output to screen with double-type command:
                             type temp.txt & type temp.txt 1>&2
                        - then when running batchfile you from command prompt. "script.bat 2>log.txt"

                    2. convert the code to vbscript, and use wscript.stdout.read method???

                    3. should be a something more simpler solution exist, but my brain stuck  :(

                    Dias de verano

                    • Guest
                    Re: how can i stop batch/cmd from erasing old lines?
                    « Reply #13 on: May 20, 2009, 09:01:47 AM »
                    Important to know the difference between > and >>


                    Reno



                      Hopeful
                    • Thanked: 32
                      Re: how can i stop batch/cmd from erasing old lines?
                      « Reply #14 on: May 20, 2009, 09:28:36 AM »
                      Important to know the difference between > and >>



                      answer: post #2