By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

Redirect StandartOutput and StandardInput at the same time without closing the executive

P: n/a
Hi all,

Thanks for reading my post!!!

I am facing a problem that I cannot redirect StandartOutput and
StandardInput at the same time without closing the executive.

Actually, I have a console application named "etm.exe", I would like
to call it in my .net (VC) application. What I want to do is when the
user type some command in my .net application, I redirect this command
to etm.exe and also redirect the output of "etm.exe" to my .net
application. Also, I need the "etm.exe" not to be closed until I close
my .net application.

I have tried by using "process" class, I can redirect the input and
output. However, the "etm.exe" is closed every time a single command
completed.

Has anyone tried to develop a similar application?
Thanks in advance. Your help is greatly appreicated!!!

Ivan Lam
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Couple things to look for.

In your etm.exe are you ever calling Console.Out.Flush()? This will flush
what is in the buffer to the Stream.

In your application how are you redirecting the standard output?

Process p;
p.StandardOutput.ReadToEnd().

If you are calling ReadToEnd, it will not read it until I think the stream
is closed. ie the etm.exe has exited. You might want to look at some other
methods Read, ReadLine to get better functionality.

The only time you can send information easily to another process is through
the process start info object. You can only pass command arguments to the
exe.

To pass commands to the etm.exe while it is running, you will have to look
into remoting, or some sort of RPC call to send commands to a seperate
process.

So this might have not helped you at all, but hopefully you have more
insight into your problem.

bill

"Ivan Lam" <iv*****@hkem.com> wrote in message
news:77*************************@posting.google.co m...
Hi all,

Thanks for reading my post!!!

I am facing a problem that I cannot redirect StandartOutput and
StandardInput at the same time without closing the executive.

Actually, I have a console application named "etm.exe", I would like
to call it in my .net (VC) application. What I want to do is when the
user type some command in my .net application, I redirect this command
to etm.exe and also redirect the output of "etm.exe" to my .net
application. Also, I need the "etm.exe" not to be closed until I close
my .net application.

I have tried by using "process" class, I can redirect the input and
output. However, the "etm.exe" is closed every time a single command
completed.

Has anyone tried to develop a similar application?
Thanks in advance. Your help is greatly appreicated!!!

Ivan Lam

Nov 19 '05 #2

P: n/a
We are working on getting access to a running process in an ASP.NET Web App
which needs to access a running process, send messages to it, on different
requests. What we did was create the process on the first request, then
withing the .exe itself, we had a while loop like while((read =
Console.ReadLine()) != null) This seems to keep the .exe running and
accepting input. Using that, we were able to have our asp.net grab hold of
the running process, and send it commands pretty easily. If you have anymore
input on this we have some issues on it we've been battling for ASP.NET such
as how to grab hold of the StandardInput Stream on a second request since the
stream is closed. Right now we cache an opened StreamWriter object but that
seems a little brittle. Any ideas on that one?

Christopher

"Ivan Lam" wrote:
Hi all,

Thanks for reading my post!!!

I am facing a problem that I cannot redirect StandartOutput and
StandardInput at the same time without closing the executive.

Actually, I have a console application named "etm.exe", I would like
to call it in my .net (VC) application. What I want to do is when the
user type some command in my .net application, I redirect this command
to etm.exe and also redirect the output of "etm.exe" to my .net
application. Also, I need the "etm.exe" not to be closed until I close
my .net application.

I have tried by using "process" class, I can redirect the input and
output. However, the "etm.exe" is closed every time a single command
completed.

Has anyone tried to develop a similar application?
Thanks in advance. Your help is greatly appreicated!!!

Ivan Lam

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.