Click here to Skip to main content
15,893,923 members

Capture ALL (stdout, stderr AND CON) output of cmd executing plink

MayFlyJJ asked:

Open original thread
Hi all,

its my first time posting a coding question.. I am getting crazy with the following case (searching the internet for a couple of days):
I want to open SSH connections from c# via opening a process and running plink. All output should be collected and depending on the results the program will fire actions to the ssh.
My big problem is, that i am using a couple if different scripts and i need user interaction. therefore i have to capture ALL output data (standard output, standard error AND CONSOLE).

Looking at the following test batch should make the case more clear:
1: @ECHO OFF
2: ECHO StdOut
3: ECHO StdErr 1>&2
4: ECHO Cons>CON

I am able to capture lines 2+3, but not 4 (used by some programs).
I have also tried powershell instead of cmd.exe as starting point, but same result.

Is there any way in c# to capture the console out as well or do you know any third party command line being able to redirect CON out to stdout or something like this?

any help is really appreciated. Thanks a lot!
Michael
Tags: C#, Process, Redirection, SSH, Console

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900