Problems getting desired output from Command line process










0














I am trying to add Windows natives notifications for the lftp linux process.
To do that I'm trying to launch the command from c# Console App to catch the status of lftp.
The problem is that I don't have the same output if I launch it from c# that if I run it from bash.



I have an helper class to do my Command Line calls :



public static class ShellHelper

public static void Bash(this string cmd)

var escapedArgs = cmd.Replace(""", "\"");

var process = new Process()

StartInfo = new ProcessStartInfo

FileName = "C:/cygwin64/bin/sh.exe",
Arguments = $"-c "escapedArgs"",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
WindowStyle = ProcessWindowStyle.Hidden,

;

process.OutputDataReceived += new DataReceivedEventHandler(ReadOutput);
process.ErrorDataReceived += new DataReceivedEventHandler(ErrorOutput);

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();


private static void ErrorOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine("Error: " + e.Data);



private static void ReadOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine(e.Data);





And my call is :



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; "");


This is the expected output that I get when I launch the command from bash



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`Kaamelott - S01E17 - Le Signe.mkv', got 0 of 48941955 (0%)
............................................................................................................................................................................................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 32768 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 131072 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 458752 of 48941955 (0%) 235.7K/s
oo.............................................................................. ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 720896 of 48941955 (1%) 265.0K/s


And this is what I get when I launch the same command from c# :



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`...1E17 - Le Signe.mkv', got 0 of 48941955 (0%)
`...1E17 - Le Signe.mkv', got 131072 of 48941955(0%)..........................
`...1E17 - Le Signe.mkv', got 917504 of 48941955 (1%) 598.5K/s.................
`...1E17 - Le Signe.mkv', got 1671168 of 48941955 (3%) 730.4K/s ..............
`...1E17 - Le Signe.mkv', got 1900544 of 48941955 (3%) 734.7K/s .............
`...1E17 - Le Signe.mkv', got 2588672 of 48941955 (5%) 650.1K/s .............
`...1E17 - Le Signe.mkv', got 3473408 of 48941955 (7%) 727.3K/s .............
`...1E17 - Le Signe.mkv', got 4096000 of 48941955 (8%) 718.8K/s .............
`...1E17 - Le Signe.mkv', got 4816896 of 48941955 (9%) 747.9K/s .............
`...1E17 - Le Signe.mkv', got 5668864 of 48941955 (11%) 954.0K/s .............


As you can see the name of the file is truncate.
My guess is it's maybe a buffer size problem or an encoding format problem with some specials chars that c# doesn't like.



I also tried to directly redirect the output in a file from the command like so:



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; " > output.log");


But it's the same, works like a charm from bash but missing parts when I launch from c#..



Any ideas on what's happening here?



EDIT : Someone posted a comment (and deleted it??) and pointed out that the maximum number of characters that "c#" give me by output line is 80. He asked me to resize the Console with



Console.SetWindowSize(400, 800);


at the begining of my program but it doesn't changed anything. But the 80 chars max is probably an interresting remark!



EDIT 2: I cleaned up the output of lftp with a sed command to remove the progress bar and only get the name of the file and it's progression. But still the output is truncate when I launch my script from C#.
I did a test with an extremly short file name (yo.mkv) and everything is here! So I think it's definitly a buffer size problem of StandardOutput. Is there a way to define a bigger size of this buffer?










share|improve this question























  • I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
    – qualinost
    Nov 7 '18 at 16:40











  • I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
    – raterus
    Nov 7 '18 at 17:17










  • Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
    – qualinost
    Nov 7 '18 at 17:39











  • Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
    – qualinost
    Nov 7 '18 at 17:49







  • 1




    Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
    – raterus
    Nov 7 '18 at 20:28















0














I am trying to add Windows natives notifications for the lftp linux process.
To do that I'm trying to launch the command from c# Console App to catch the status of lftp.
The problem is that I don't have the same output if I launch it from c# that if I run it from bash.



I have an helper class to do my Command Line calls :



public static class ShellHelper

public static void Bash(this string cmd)

var escapedArgs = cmd.Replace(""", "\"");

var process = new Process()

StartInfo = new ProcessStartInfo

FileName = "C:/cygwin64/bin/sh.exe",
Arguments = $"-c "escapedArgs"",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
WindowStyle = ProcessWindowStyle.Hidden,

;

process.OutputDataReceived += new DataReceivedEventHandler(ReadOutput);
process.ErrorDataReceived += new DataReceivedEventHandler(ErrorOutput);

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();


private static void ErrorOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine("Error: " + e.Data);



private static void ReadOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine(e.Data);





And my call is :



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; "");


This is the expected output that I get when I launch the command from bash



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`Kaamelott - S01E17 - Le Signe.mkv', got 0 of 48941955 (0%)
............................................................................................................................................................................................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 32768 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 131072 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 458752 of 48941955 (0%) 235.7K/s
oo.............................................................................. ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 720896 of 48941955 (1%) 265.0K/s


And this is what I get when I launch the same command from c# :



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`...1E17 - Le Signe.mkv', got 0 of 48941955 (0%)
`...1E17 - Le Signe.mkv', got 131072 of 48941955(0%)..........................
`...1E17 - Le Signe.mkv', got 917504 of 48941955 (1%) 598.5K/s.................
`...1E17 - Le Signe.mkv', got 1671168 of 48941955 (3%) 730.4K/s ..............
`...1E17 - Le Signe.mkv', got 1900544 of 48941955 (3%) 734.7K/s .............
`...1E17 - Le Signe.mkv', got 2588672 of 48941955 (5%) 650.1K/s .............
`...1E17 - Le Signe.mkv', got 3473408 of 48941955 (7%) 727.3K/s .............
`...1E17 - Le Signe.mkv', got 4096000 of 48941955 (8%) 718.8K/s .............
`...1E17 - Le Signe.mkv', got 4816896 of 48941955 (9%) 747.9K/s .............
`...1E17 - Le Signe.mkv', got 5668864 of 48941955 (11%) 954.0K/s .............


As you can see the name of the file is truncate.
My guess is it's maybe a buffer size problem or an encoding format problem with some specials chars that c# doesn't like.



I also tried to directly redirect the output in a file from the command like so:



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; " > output.log");


But it's the same, works like a charm from bash but missing parts when I launch from c#..



Any ideas on what's happening here?



EDIT : Someone posted a comment (and deleted it??) and pointed out that the maximum number of characters that "c#" give me by output line is 80. He asked me to resize the Console with



Console.SetWindowSize(400, 800);


at the begining of my program but it doesn't changed anything. But the 80 chars max is probably an interresting remark!



EDIT 2: I cleaned up the output of lftp with a sed command to remove the progress bar and only get the name of the file and it's progression. But still the output is truncate when I launch my script from C#.
I did a test with an extremly short file name (yo.mkv) and everything is here! So I think it's definitly a buffer size problem of StandardOutput. Is there a way to define a bigger size of this buffer?










share|improve this question























  • I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
    – qualinost
    Nov 7 '18 at 16:40











  • I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
    – raterus
    Nov 7 '18 at 17:17










  • Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
    – qualinost
    Nov 7 '18 at 17:39











  • Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
    – qualinost
    Nov 7 '18 at 17:49







  • 1




    Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
    – raterus
    Nov 7 '18 at 20:28













0












0








0







I am trying to add Windows natives notifications for the lftp linux process.
To do that I'm trying to launch the command from c# Console App to catch the status of lftp.
The problem is that I don't have the same output if I launch it from c# that if I run it from bash.



I have an helper class to do my Command Line calls :



public static class ShellHelper

public static void Bash(this string cmd)

var escapedArgs = cmd.Replace(""", "\"");

var process = new Process()

StartInfo = new ProcessStartInfo

FileName = "C:/cygwin64/bin/sh.exe",
Arguments = $"-c "escapedArgs"",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
WindowStyle = ProcessWindowStyle.Hidden,

;

process.OutputDataReceived += new DataReceivedEventHandler(ReadOutput);
process.ErrorDataReceived += new DataReceivedEventHandler(ErrorOutput);

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();


private static void ErrorOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine("Error: " + e.Data);



private static void ReadOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine(e.Data);





And my call is :



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; "");


This is the expected output that I get when I launch the command from bash



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`Kaamelott - S01E17 - Le Signe.mkv', got 0 of 48941955 (0%)
............................................................................................................................................................................................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 32768 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 131072 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 458752 of 48941955 (0%) 235.7K/s
oo.............................................................................. ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 720896 of 48941955 (1%) 265.0K/s


And this is what I get when I launch the same command from c# :



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`...1E17 - Le Signe.mkv', got 0 of 48941955 (0%)
`...1E17 - Le Signe.mkv', got 131072 of 48941955(0%)..........................
`...1E17 - Le Signe.mkv', got 917504 of 48941955 (1%) 598.5K/s.................
`...1E17 - Le Signe.mkv', got 1671168 of 48941955 (3%) 730.4K/s ..............
`...1E17 - Le Signe.mkv', got 1900544 of 48941955 (3%) 734.7K/s .............
`...1E17 - Le Signe.mkv', got 2588672 of 48941955 (5%) 650.1K/s .............
`...1E17 - Le Signe.mkv', got 3473408 of 48941955 (7%) 727.3K/s .............
`...1E17 - Le Signe.mkv', got 4096000 of 48941955 (8%) 718.8K/s .............
`...1E17 - Le Signe.mkv', got 4816896 of 48941955 (9%) 747.9K/s .............
`...1E17 - Le Signe.mkv', got 5668864 of 48941955 (11%) 954.0K/s .............


As you can see the name of the file is truncate.
My guess is it's maybe a buffer size problem or an encoding format problem with some specials chars that c# doesn't like.



I also tried to directly redirect the output in a file from the command like so:



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; " > output.log");


But it's the same, works like a charm from bash but missing parts when I launch from c#..



Any ideas on what's happening here?



EDIT : Someone posted a comment (and deleted it??) and pointed out that the maximum number of characters that "c#" give me by output line is 80. He asked me to resize the Console with



Console.SetWindowSize(400, 800);


at the begining of my program but it doesn't changed anything. But the 80 chars max is probably an interresting remark!



EDIT 2: I cleaned up the output of lftp with a sed command to remove the progress bar and only get the name of the file and it's progression. But still the output is truncate when I launch my script from C#.
I did a test with an extremly short file name (yo.mkv) and everything is here! So I think it's definitly a buffer size problem of StandardOutput. Is there a way to define a bigger size of this buffer?










share|improve this question















I am trying to add Windows natives notifications for the lftp linux process.
To do that I'm trying to launch the command from c# Console App to catch the status of lftp.
The problem is that I don't have the same output if I launch it from c# that if I run it from bash.



I have an helper class to do my Command Line calls :



public static class ShellHelper

public static void Bash(this string cmd)

var escapedArgs = cmd.Replace(""", "\"");

var process = new Process()

StartInfo = new ProcessStartInfo

FileName = "C:/cygwin64/bin/sh.exe",
Arguments = $"-c "escapedArgs"",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
WindowStyle = ProcessWindowStyle.Hidden,

;

process.OutputDataReceived += new DataReceivedEventHandler(ReadOutput);
process.ErrorDataReceived += new DataReceivedEventHandler(ErrorOutput);

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();


private static void ErrorOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine("Error: " + e.Data);



private static void ReadOutput(object sender, DataReceivedEventArgs e)

if (e.Data != null)

Console.WriteLine(e.Data);





And my call is :



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; "");


This is the expected output that I get when I launch the command from bash



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`Kaamelott - S01E17 - Le Signe.mkv', got 0 of 48941955 (0%)
............................................................................................................................................................................................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 32768 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 131072 of 48941955 (0%)
................................................................................ ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 458752 of 48941955 (0%) 235.7K/s
oo.............................................................................. ................................................................................ .............................................................................
[A`Kaamelott - S01E17 - Le Signe.mkv', got 720896 of 48941955 (1%) 265.0K/s


And this is what I get when I launch the same command from c# :



cd `/home29/qualinost/files/tests' [Connecting...]
cd `/home29/qualinost/files/tests' [Connected]
`...1E17 - Le Signe.mkv', got 0 of 48941955 (0%)
`...1E17 - Le Signe.mkv', got 131072 of 48941955(0%)..........................
`...1E17 - Le Signe.mkv', got 917504 of 48941955 (1%) 598.5K/s.................
`...1E17 - Le Signe.mkv', got 1671168 of 48941955 (3%) 730.4K/s ..............
`...1E17 - Le Signe.mkv', got 1900544 of 48941955 (3%) 734.7K/s .............
`...1E17 - Le Signe.mkv', got 2588672 of 48941955 (5%) 650.1K/s .............
`...1E17 - Le Signe.mkv', got 3473408 of 48941955 (7%) 727.3K/s .............
`...1E17 - Le Signe.mkv', got 4096000 of 48941955 (8%) 718.8K/s .............
`...1E17 - Le Signe.mkv', got 4816896 of 48941955 (9%) 747.9K/s .............
`...1E17 - Le Signe.mkv', got 5668864 of 48941955 (11%) 954.0K/s .............


As you can see the name of the file is truncate.
My guess is it's maybe a buffer size problem or an encoding format problem with some specials chars that c# doesn't like.



I also tried to directly redirect the output in a file from the command like so:



ShellHelper.Bash("unbuffer lftp -p 22 -u login,password sftp://XXXXXX -e "set mirror:use-pget-n 20; mirror --parallel=3 -c -P5 /home29/qualinost/files/tests ./tests; quit; " > output.log");


But it's the same, works like a charm from bash but missing parts when I launch from c#..



Any ideas on what's happening here?



EDIT : Someone posted a comment (and deleted it??) and pointed out that the maximum number of characters that "c#" give me by output line is 80. He asked me to resize the Console with



Console.SetWindowSize(400, 800);


at the begining of my program but it doesn't changed anything. But the 80 chars max is probably an interresting remark!



EDIT 2: I cleaned up the output of lftp with a sed command to remove the progress bar and only get the name of the file and it's progression. But still the output is truncate when I launch my script from C#.
I did a test with an extremly short file name (yo.mkv) and everything is here! So I think it's definitly a buffer size problem of StandardOutput. Is there a way to define a bigger size of this buffer?







c# bash command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 '18 at 9:23







qualinost

















asked Nov 7 '18 at 16:23









qualinostqualinost

165




165











  • I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
    – qualinost
    Nov 7 '18 at 16:40











  • I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
    – raterus
    Nov 7 '18 at 17:17










  • Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
    – qualinost
    Nov 7 '18 at 17:39











  • Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
    – qualinost
    Nov 7 '18 at 17:49







  • 1




    Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
    – raterus
    Nov 7 '18 at 20:28
















  • I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
    – qualinost
    Nov 7 '18 at 16:40











  • I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
    – raterus
    Nov 7 '18 at 17:17










  • Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
    – qualinost
    Nov 7 '18 at 17:39











  • Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
    – qualinost
    Nov 7 '18 at 17:49







  • 1




    Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
    – raterus
    Nov 7 '18 at 20:28















I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
– qualinost
Nov 7 '18 at 16:40





I just tried to add : Console.SetWindowSize(400, 800); before the call but nothing changed... You're probably in the good way because the 3 dots '...' before the truncate file name is probably because it can't display the whole string...
– qualinost
Nov 7 '18 at 16:40













I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
– raterus
Nov 7 '18 at 17:17




I believe your problem is due to the progress bars, those use lots of control characters that are difficult to capture in standard output as they are constantly changing. Have you looked at the logging options of this utility 'unbuffer' to see if there is a way to set a more standard logging that doesn't use progress bars?
– raterus
Nov 7 '18 at 17:17












Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
– qualinost
Nov 7 '18 at 17:39





Sadly I don't have the hand on the lftp output. unbuffer is just a script from the expect package which I added to cygwin. It allows me to unbuffer the "dynamic" output of lftp.
– qualinost
Nov 7 '18 at 17:39













Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
– qualinost
Nov 7 '18 at 17:49





Is a backtick could be a problem in the stream output in C# ? In the full output I can see that I always have those characters before the cut [A` ?
– qualinost
Nov 7 '18 at 17:49





1




1




Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
– raterus
Nov 7 '18 at 20:28




Lose the async reads here (BeginOutputReadLine) and process the ProcessInfo.StandardOutput stream directly by using the Read() method. See: docs.microsoft.com/en-us/dotnet/api/…
– raterus
Nov 7 '18 at 20:28












1 Answer
1






active

oldest

votes


















0














I finally found a workaround on this broken MS async output redirection.
I used this code https://stackoverflow.com/a/13860551/1502444 to be able to read each chars of the output by using StandardOutput.Read() method in a different thread and changing the Read buffer size.
Would like to thanks the author of this solution and raterus to pointed out the async read problem.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193626%2fproblems-getting-desired-output-from-command-line-process%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I finally found a workaround on this broken MS async output redirection.
    I used this code https://stackoverflow.com/a/13860551/1502444 to be able to read each chars of the output by using StandardOutput.Read() method in a different thread and changing the Read buffer size.
    Would like to thanks the author of this solution and raterus to pointed out the async read problem.






    share|improve this answer

























      0














      I finally found a workaround on this broken MS async output redirection.
      I used this code https://stackoverflow.com/a/13860551/1502444 to be able to read each chars of the output by using StandardOutput.Read() method in a different thread and changing the Read buffer size.
      Would like to thanks the author of this solution and raterus to pointed out the async read problem.






      share|improve this answer























        0












        0








        0






        I finally found a workaround on this broken MS async output redirection.
        I used this code https://stackoverflow.com/a/13860551/1502444 to be able to read each chars of the output by using StandardOutput.Read() method in a different thread and changing the Read buffer size.
        Would like to thanks the author of this solution and raterus to pointed out the async read problem.






        share|improve this answer












        I finally found a workaround on this broken MS async output redirection.
        I used this code https://stackoverflow.com/a/13860551/1502444 to be able to read each chars of the output by using StandardOutput.Read() method in a different thread and changing the Read buffer size.
        Would like to thanks the author of this solution and raterus to pointed out the async read problem.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 7:28









        qualinostqualinost

        165




        165



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193626%2fproblems-getting-desired-output-from-command-line-process%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線