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

Author Topic: Copy DOS screen after it's Displayed  (Read 9549 times)

0 Members and 1 Guest are viewing this topic.

timrob

    Topic Starter


    Intermediate
    Copy DOS screen after it's Displayed
    « on: January 24, 2010, 04:45:28 PM »
    Is there a way to copy a DOS screen to a text file via a batch file, after it's displayed in the command window?

    I'm running a batch file, if one of the commands fails, I only want to log the DOS screen if it fails.

    I know how to start a log from the beginning, but that's one more process I don't want to run if not necessary.

    BillRichardson



      Intermediate

      Thanked: 15
      Re: Copy DOS screen after it's Displayed
      « Reply #1 on: January 24, 2010, 05:11:09 PM »
      Is there a way to copy a DOS screen to a text file via a batch file, after it's displayed in the command window?


      C:\batch>type  timrob.bat

      Code: [Select]
      @echo off

      type timrob.txt


      echo.  >> timrob.txt

      type timrob.txt  >>  timrob2.txt

      echo. >>  timrob2.txt

      type  timrob2.txt

      Output:

      C:\batch>timrob.bat

      Copy DOS screen after it's Displayed



      Is there a way to copy a DOS screen to a text file via a batch file,
      after it's displayed in the command window?

      I'm running a batch file, if one of the commands fails, I only want
      to log the DOS screen if it fails.

      I know how to start a log from the beginning, but that's one more
      process I don't want to run if not necessary.
      Copy DOS screen after it's Displayed



      Is there a way to copy a DOS screen to a text file via a batch file,
      after it's displayed in the command window?

      I'm running a batch file, if one of the commands fails, I only want
      to log the DOS screen if it fails.

      I know how to start a log from the beginning, but that's one more
      process I don't want to run if not necessary.

      Copy DOS screen after it's Displayed



      Is there a way to copy a DOS screen to a text file via a batch file,
      after it's displayed in the command window?

      I'm running a batch file, if one of the commands fails, I only want
      to log the DOS screen if it fails.

      I know how to start a log from the beginning, but that's one more
      process I don't want to run if not necessary.


      C:\batch>
      Bill Richardson

      BillRichardson



        Intermediate

        Thanked: 15
        Re: Copy DOS screen after it's Displayed
        « Reply #2 on: January 24, 2010, 05:17:16 PM »
        1) Point to Bar at top of screen, right click, choose select all
        and then  choose copy
        2) Paste to image editor and save
        3) Upload to phobucket.com
        4) Copy image code and paste image code  to here

        « Last Edit: January 24, 2010, 05:27:49 PM by BillRichardson »
        Bill Richardson

        Helpmeh



          Guru

        • Roar.
        • Thanked: 123
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 8
        Re: Copy DOS screen after it's Displayed
        « Reply #3 on: January 24, 2010, 07:28:38 PM »
        To check if a command fails, add this on the SAME LINE after the desired command.

        && Echo "INSERT COMMAND HERE" failed - %time% - %date% >errors.log
        Where's MagicSpeed?
        Quote from: 'matt'
        He's playing a game called IRL. Great graphics, *censored* gameplay.

        Dusty



          Egghead

        • I could if she would, but she won't so I don't.
        • Thanked: 75
        • Experience: Beginner
        • OS: Windows XP
        Re: Copy DOS screen after it's Displayed
        « Reply #4 on: January 24, 2010, 09:51:15 PM »
        Helpmeh - you sure about that?  Should the character not be || for failure?

        http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true
        Quote
        && Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.

        || Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
        One good deed is worth more than a year of good intentions.

        Helpmeh



          Guru

        • Roar.
        • Thanked: 123
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 8
        Re: Copy DOS screen after it's Displayed
        « Reply #5 on: January 25, 2010, 08:40:39 AM »
        Helpmeh - you sure about that?  Should the character not be || for failure?

        http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true
        Hmmm...I thought it was the other way around. Oh well, good for you for catching that.
        Where's MagicSpeed?
        Quote from: 'matt'
        He's playing a game called IRL. Great graphics, *censored* gameplay.

        Salmon Trout

        • Guest
        Re: Copy DOS screen after it's Displayed
        « Reply #6 on: January 25, 2010, 11:25:14 AM »
        Hmmm...I thought it was the other way around. Oh well, good for you for catching that.

        How hard is it to test?

        Code: [Select]
        C:\>set test=eggs

        C:\>echo %test% | find "eggs">nul && echo success
        success

        C:\>@echo %test% | find "bacon">nul || echo failure
        failure

        Helpmeh



          Guru

        • Roar.
        • Thanked: 123
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 8
        Re: Copy DOS screen after it's Displayed
        « Reply #7 on: January 25, 2010, 11:48:20 AM »
        How hard is it to test?

        Code: [Select]
        C:\>set test=eggs

        C:\>echo %test% | find "eggs">nul && echo success
        success

        C:\>@echo %test% | find "bacon">nul || echo failure
        failure
        Well I don't think you can make batch scripts on an iPod Touch.
        Where's MagicSpeed?
        Quote from: 'matt'
        He's playing a game called IRL. Great graphics, *censored* gameplay.

        Salmon Trout

        • Guest
        Re: Copy DOS screen after it's Displayed
        « Reply #8 on: January 25, 2010, 12:39:51 PM »
        Well I don't think you can make batch scripts on an iPod Touch.

        I guess... maybe one day you'll get a proper computer?

        timrob

          Topic Starter


          Intermediate
          Re: Copy DOS screen after it's Displayed
          « Reply #9 on: January 25, 2010, 02:17:43 PM »
          Helpmeh,
          As an example, I used
          Echo xcopy failed - %time% - %date% >errors.log
          without the && and it works.  I don't know what the && are for.

          I'll try to incorporate the new code into the batch file.  In my old code, to confirm the batch file was copying correctly, I was comparing the number of megabytes.  My way was a much longer way.

          I was also using xcopy with /v. 

          Bill,
          I just get blank files with your code.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Copy DOS screen after it's Displayed
          « Reply #10 on: January 25, 2010, 02:32:37 PM »
          I am watching this thread. Does the OP really mean that he wants to capture the errors messages as a text file and he does not know where the error will occur?
          And this all has to be in batch file and run without operator assistance? He wants something to read the text from the screen?
          Can you do that inside of DOS?



          timrob

            Topic Starter


            Intermediate
            Re: Copy DOS screen after it's Displayed
            « Reply #11 on: January 25, 2010, 02:54:03 PM »
            I am watching this thread. Does the OP really mean that he wants to capture the errors messages as a text file and he does not know where the error will occur?
            And this all has to be in batch file and run without operator assistance? He wants something to read the text from the screen?
              Yes, that's what I'm asking.  I don't know if it's possible.

            BillRichardson



              Intermediate

              Thanked: 15
              Re: Copy DOS screen after it's Displayed
              « Reply #12 on: January 25, 2010, 03:47:29 PM »
              http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

              Timrob:

              Does the Timrob really mean that he wants to capture the errors messages
              as a text file?


              Standard Input, Standard Output, and Standard Error
              When a command begins running, it usually expects that three files are
              already open: standard input, standard output, and standard error
              (sometimes called error output or diagnostic output). A number,
              called a file descriptor, is associated with each of these files, as follows:
              File descriptor 0  Standard input 
              File descriptor 1  Standard output 
              File descriptor 2  Standard error (diagnostic) output


              Standard error, sometimes denoted as stderr, is where error messages go.
              By default, this is your screen.


              These default actions of input and output can be varied.


              We can use a file as input and write results of a command to a file.
              This is called input/output redirection, ">" or ">>" 

               

              Use redirection, "2>", to a text file for the error message.

              We can easily display a message to the screen from a text file.
              The type command?
              Notepad?


              Redirection
              You may be familiar with "redirection to NUL" to hide command output:

              ECHO Hello world>NULwill show nothing on screen.
              That's because >NUL redirects all Standard Output to the NUL device, which does nothing but discard it.

              EHCO Hello world>NUL
              « Last Edit: January 25, 2010, 04:01:52 PM by BillRichardson »
              Bill Richardson

              timrob

                Topic Starter


                Intermediate
                Re: Copy DOS screen after it's Displayed
                « Reply #13 on: January 25, 2010, 04:06:16 PM »
                Sorry, I misread your statement.  I meant I wanted to capture what ever is on the DOS screen.

                BillRichardson



                  Intermediate

                  Thanked: 15
                  Re: Copy DOS screen after it's Displayed
                  « Reply #14 on: January 25, 2010, 04:17:20 PM »
                  I meant I wanted to capture what ever is on the DOS screen.

                  Capture with redirection to a text file before a screen display. Do not allow a screen display.

                  ( You may latter display the contents of the text file to the screen.)
                  Bill Richardson