15,617,173 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Johannes Grunedal (Top 7 by date)
Johannes Grunedal
20-Apr-15 5:01am
View
Great! Hmm, I was wondering. As I said, I suspect the problem could be in my external application but shouldn't be able to read and write to a standard cmd window? I mean if I just pass cmd.exe as command? However, that doesn't work either. I can only read once AFTER the cmd window is closed (by me). Maybe that could be a clue to what is going on...
Your "5" is coming sooooon ;)
Johannes Grunedal
20-Apr-15 4:24am
View
Hi again!
I give you 4 for the quick answer and for the complete class. It doesn't do exactly as I want but that may be an internal problem of my application.
Johannes Grunedal
18-Apr-15 3:39am
View
Ah, that could maybe explain it. I notice that a console window pops up and when I close, I can read the first result. I think that is why the SendCommand doesn't work, the 'process' or console is closed. I'm trying to figure out why and how to prevent that from happening.
Thanks for all the help.
Johannes Grunedal
17-Apr-15 17:09pm
View
Wow!
I'm impressed with all the effort you have put down into this.
I must admit your'e out of my league and I have some catching up do to ;)
I was forced to do some small adjustments to make your code compile and maybe I messed things up (I'm sure the errors are on my side):
I replaced the queue 'output' with 'Output', moved up the _process.Start() before the '_inputStreamWriter = _process.StandardInput;' line.
The process still 'seem' to get closed because I read valid data only the first time and no matter how many times I run the SendCommand function it doesn't seem to 'bite'. I tried to debug but I haven't found where exactly the problem lies. When I debug I get an exception here:
if (args.Data == null)
{
//the pipe has closed. i.e. the process has ended
_waitHandles[1].Set();
}
And to get rid of that I needed to add this:
_waitHandles[1] = new ManualResetEvent(false);
Don't get me wrong, I really appreciate the help from you, I just try to explain my point of view. I'm sure the problem is on my side somewhere.
I will dig deeper tomorrow.
Have a nice weekend.
Johannes Grunedal
17-Apr-15 9:27am
View
Hi again!
My commands looks like this. RunExternalApplication.exe, listUnit, ReadCommand, WriteCommand etc.
After each sent command the application return with success info and actual data (that's why I need to keep the 'line' open).
No, I can't (or rather not) choose to log in every time since it may take up to one minute for each login procedure to complete (stupid system which communicates with aonther hardware).
So if possible, a one time login followed by severel commands is of great importance.
However, thanks for clarifying how the redirecting works, much appreciated.
Regards
Cypres
Johannes Grunedal
17-Apr-15 8:22am
View
Hi again!
Thanks for helping me out. It almost works, I had to do these modifications:
startInfo.RedirectStandardOutput = true;// false;
startInfo.RedirectStandardError = true; // false;
startInfo.RedirectStandardInput = true; // new
But, I can only start up the application once with one command (the process seem to close right after). I need to be able to send multiple commands and read multiple responses. I tried to break out the Process and StartInfo to make them public but that doesn't do the trick.
Regards Cypres
Johannes Grunedal
17-Apr-15 6:20am
View
Hi Andy!
Thanks for quick reply. Well, I start the 'other' program from the cmd.exe command and from that I need to send and receive data. I'm not sure how you mean by not using the terminal. Could you explain please! I'm afraid Linux is not an option here.
Show More