[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Interacting with other console applications.

schmrz

11/11/2008 9:54:00 AM

Is there any industry standard for doing this? I wrote a C# class for doing
this and it's working flawless when interacting with cmd.exe and other .NET
console applications. But when I start ftp.exe I can't read STDOUT from that
application. Same goes for some other applications (mainly consoles for
dedicated game servers).

Is there anyone with experience in this kind of applications.

4 Answers

schmrz

11/11/2008 5:13:00 PM

0

I guess windows api functions for std redirecting are the only way to do it
.... (sadly)
"schmrz" <neko_877@hotmail.com> wrote in message
news:AD03ED4A-847B-4AC3-82E3-ABA32BAE7158@microsoft.com...
> Is there any industry standard for doing this? I wrote a C# class for
> doing this and it's working flawless when interacting with cmd.exe and
> other .NET console applications. But when I start ftp.exe I can't read
> STDOUT from that application. Same goes for some other applications
> (mainly consoles for dedicated game servers).
>
> Is there anyone with experience in this kind of applications.

Peter Duniho

11/11/2008 7:20:00 PM

0

On Tue, 11 Nov 2008 01:54:05 -0800, schmrz <neko_877@hotmail.com> wrote:

> Is there any industry standard for doing this? I wrote a C# class for
> doing this and it's working flawless when interacting with cmd.exe and
> other .NET console applications. But when I start ftp.exe I can't read
> STDOUT from that application. Same goes for some other applications
> (mainly consoles for dedicated game servers).
>
> Is there anyone with experience in this kind of applications.

I haven't bothered to experiment. But keep in mind that some applications
use stderr for message reporting, etc. If you want to capture _all_ the
output from a console application, you should be capturing both output
streams.

I would expect that in the vast majority of cases where you get nothing
from stdout, it's just because the output is going to stderr instead. The
likelihood of you coming across a console application that has completely
bypassed the normal console output mechansims is extremely low.

Pete

schmrz

11/11/2008 9:42:00 PM

0

I have tried to read stderr in a managed way and got nothing, so I'm going
to try to do it with WinAPI stdout and stdin redirection...

"Peter Duniho" <NpOeStPeAdM@nnowslpianmk.com> wrote in message
news:op.ukgynnxj8jd0ej@petes-computer.local...
> On Tue, 11 Nov 2008 01:54:05 -0800, schmrz <neko_877@hotmail.com> wrote:
>
>> Is there any industry standard for doing this? I wrote a C# class for
>> doing this and it's working flawless when interacting with cmd.exe and
>> other .NET console applications. But when I start ftp.exe I can't read
>> STDOUT from that application. Same goes for some other applications
>> (mainly consoles for dedicated game servers).
>>
>> Is there anyone with experience in this kind of applications.
>
> I haven't bothered to experiment. But keep in mind that some applications
> use stderr for message reporting, etc. If you want to capture _all_ the
> output from a console application, you should be capturing both output
> streams.
>
> I would expect that in the vast majority of cases where you get nothing
> from stdout, it's just because the output is going to stderr instead. The
> likelihood of you coming across a console application that has completely
> bypassed the normal console output mechansims is extremely low.
>
> Pete

schmrz

11/12/2008 9:00:00 AM

0

Looks like C programs use seperate IO buffers and they need to flush their
output with fflush. If they don't then redirection gets problematic. I have
read this on msdn and they say it's problematic. Does that mean it's
impossible or it can be done somehow?

"schmrz" <neko_877@hotmail.com> wrote in message
news:AD03ED4A-847B-4AC3-82E3-ABA32BAE7158@microsoft.com...
> Is there any industry standard for doing this? I wrote a C# class for
> doing this and it's working flawless when interacting with cmd.exe and
> other .NET console applications. But when I start ftp.exe I can't read
> STDOUT from that application. Same goes for some other applications
> (mainly consoles for dedicated game servers).
>
> Is there anyone with experience in this kind of applications.