DOS command redirects file output

I have a command line tool that typically dumps about 200 lines of output. I am looking for the text that appears at the end of this conclusion. When I redirect the output to a file:

C:\> somecommand > results.txt 2>&1

... only the first 100 lines of output are displayed in this file. Similarly, if I pass the output to something like "findstr", the receiving program will not be able to find or use any text after about the 100th line.

The screen buffer size settings for the shell do not seem to affect the number of lines that can be written.

Any ideas what is going on here? For what it's worth, the team in question is iscmdbld.exe from InstallShield 2012.

This problem does not occur with other commands programmed by me (for example, "dir").

The full output of the program can be viewed only when the command is run in the cmd window.

+5
source share
4 answers

Well, unfortunately, I do not have InstallShield, so it will be quite difficult for me to run some kind of test, but I have a cam for programs that do not work, as they should do when it comes to processing input and output. In the normal case, ">" should have a NO restriction, I use it a lot on a Windows server that runs ghostscript and other old dos programs in the background, and the only way to transfer output to a file is to use>, sometimes I have files from several MB , so 200 lines really have to do something with the current exe.

, , tee32, , dos . , , .

: , , , , , :

, .

+2

, :

somecommand > results.txt 2>&1 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 9>&1

, - MSDOS TSR, .

+1

#, .

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaptureCMDOutput
{
    class Program
    {
        static string _Filename = @"sc.exe";
        static string _Arguments = @"query";
        static string _outputfile = @"c:\debug.txt";

        static void Main(string[] args)
        {
            var processStartInfo = new ProcessStartInfo
            {
                FileName = _Filename, // Exe file to run
                Arguments = _Arguments, // Arguments to exe file
                RedirectStandardOutput = true,
                UseShellExecute = false
            };

            var process = Process.Start(processStartInfo);
            process.OutputDataReceived += process_OutputDataReceived;
            process.BeginOutputReadLine();
            process.WaitForExit();
            process.CancelOutputRead();

            Console.ReadKey();
        }

        static void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            Console.WriteLine(e.Data);

            using (StreamWriter writer = new StreamWriter(_outputfile, true))
            {
                writer.WriteLine(e.Data);
            }
        }


    }
}
+1

Another idea is to add ('β†’') rather start a new one ('>'). However, I cannot think of how to even generate what you see without knowing more about my problem.

0
source

All Articles