What I try to accomplish is to run "telnet.exe" as a process in C#.
The C#-code below works with terminating commands, e.g. a
"HelloWorld.exe".
Since I'd like to communicate with "telnet" the process is still
running when I already have to read from the stream. This seems to be
the problem, since "myStreamReader.ReadLine()" is waiting for
something.
Is there a chance to force the underlying pipe to flush its output (at
least the password line should be there), so that I can read
immediately.
Any Ideas?
Regards HW
--------
Code:
namespace Telnet
{
class Telnet
{
static void Main(string[] args)
{
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new
ProcessStartInfo("telnet", "192.168.0.1");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
StreamWriter myStreamWriter = myProcess.StandardInput;
// problem, here it hangs
// Read() and ReadToEnd() also hangs!
string myString = myStreamReader.ReadLine(); <=PROBLEM ?
....
....
....
Purpose of the application:
What I want to do is call a remote application, read the telnet
stream, search for a string (e.g. password) and respond (e.g. by
sending he "pw")
The reason why I do not want to use a library is that I have to extend
the programm later using ssh, rsh ... 3 11419
Horst,
Instead of channeling the input/output through the command window, why
not use a programattic component for Telnet? Josh Mitts has developed one,
and you can find it at (watch for line wrap): http://www.treasureonthenet.com/net/v2/projects.asp
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Horst Walter" <un***@web.de> wrote in message
news:53**************************@posting.google.c om... What I try to accomplish is to run "telnet.exe" as a process in C#.
The C#-code below works with terminating commands, e.g. a "HelloWorld.exe".
Since I'd like to communicate with "telnet" the process is still running when I already have to read from the stream. This seems to be the problem, since "myStreamReader.ReadLine()" is waiting for something.
Is there a chance to force the underlying pipe to flush its output (at least the password line should be there), so that I can read immediately.
Any Ideas? Regards HW
-------- Code:
namespace Telnet { class Telnet { static void Main(string[] args) { Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("telnet", "192.168.0.1"); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcessStartInfo.RedirectStandardInput = true; myProcess.StartInfo = myProcessStartInfo; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; StreamWriter myStreamWriter = myProcess.StandardInput;
// problem, here it hangs // Read() and ReadToEnd() also hangs! string myString = myStreamReader.ReadLine(); <=PROBLEM ? ... ... ...
Purpose of the application:
What I want to do is call a remote application, read the telnet stream, search for a string (e.g. password) and respond (e.g. by sending he "pw")
The reason why I do not want to use a library is that I have to extend the programm later using ssh, rsh ...
Thanks for the info. Unfortunately the Site is down.
However, my idea still is to get it going with standard (.exe)
programs, because in my particular case this would be more generic:
Otherwise I'd need a lib for telnet, one for ssh, one for rsh...
Best Regards
HW
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:<#v*************@TK2MSFTNGP11.phx.gbl>... Horst,
Instead of channeling the input/output through the command window, why not use a programattic component for Telnet? Josh Mitts has developed one, and you can find it at (watch for line wrap):
http://www.treasureonthenet.com/net/v2/projects.asp
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Horst Walter" <un***@web.de> wrote in message news:53**************************@posting.google.c om... What I try to accomplish is to run "telnet.exe" as a process in C#.
The C#-code below works with terminating commands, e.g. a "HelloWorld.exe".
Since I'd like to communicate with "telnet" the process is still running when I already have to read from the stream. This seems to be the problem, since "myStreamReader.ReadLine()" is waiting for something.
Is there a chance to force the underlying pipe to flush its output (at least the password line should be there), so that I can read immediately.
Any Ideas? Regards HW
-------- Code:
namespace Telnet { class Telnet { static void Main(string[] args) { Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("telnet", "192.168.0.1"); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcessStartInfo.RedirectStandardInput = true; myProcess.StartInfo = myProcessStartInfo; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; StreamWriter myStreamWriter = myProcess.StandardInput;
// problem, here it hangs // Read() and ReadToEnd() also hangs! string myString = myStreamReader.ReadLine(); <=PROBLEM ? ... ... ...
Purpose of the application:
What I want to do is call a remote application, read the telnet stream, search for a string (e.g. password) and respond (e.g. by sending he "pw")
The reason why I do not want to use a library is that I have to extend the programm later using ssh, rsh ...
I found a C# telnet client for free http://www.klausbasan.de/misc/telnet/index.html
HW un***@web.de (Horst Walter) wrote in message news:<53**************************@posting.google. com>... What I try to accomplish is to run "telnet.exe" as a process in C#.
The C#-code below works with terminating commands, e.g. a "HelloWorld.exe".
Since I'd like to communicate with "telnet" the process is still running when I already have to read from the stream. This seems to be the problem, since "myStreamReader.ReadLine()" is waiting for something.
Is there a chance to force the underlying pipe to flush its output (at least the password line should be there), so that I can read immediately.
Any Ideas? Regards HW
-------- Code:
namespace Telnet { class Telnet { static void Main(string[] args) { Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("telnet", "192.168.0.1"); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcessStartInfo.RedirectStandardInput = true; myProcess.StartInfo = myProcessStartInfo; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; StreamWriter myStreamWriter = myProcess.StandardInput;
// problem, here it hangs // Read() and ReadToEnd() also hangs! string myString = myStreamReader.ReadLine(); <=PROBLEM ? ... ... ...
Purpose of the application:
What I want to do is call a remote application, read the telnet stream, search for a string (e.g. password) and respond (e.g. by sending he "pw")
The reason why I do not want to use a library is that I have to extend the programm later using ssh, rsh ... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: marccruz |
last post by:
Given an instance of System.Diagnostics.Process, how can I get the parent process
o
Given an instance of System.Diagnostics.Process, how can I...
|
by: Heiko Besemann |
last post by:
Dear group,
I created an aspx page using System.Diagnostics.Process() to launch
"tracert" from shell and redirect output to Response.Output which...
|
by: solex |
last post by:
Hello All,
Hopefully someone has run into this error. I have written a class(source
below) that launches a thread to monitor the StandardOutput...
|
by: andreas |
last post by:
hi,
In windows xp in the start launch menu when i put
notepad "c:\test.txt"
i get notepad with test.txt in it.
in vb.net when i state...
|
by: Nurit N |
last post by:
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.
I hope this is the...
|
by: Daniel |
last post by:
System.Diagnostics.Process.Start fails on windows server 2003
the process returns process.ExitCode == 0 but executing any process with...
|
by: Daniel |
last post by:
C# windows service freezes on System.Diagnostics.Process.Start(info)
When I launch PSCP from a C# windows service and launch pscp 0.53 there are...
|
by: Colin Williams |
last post by:
I am using the code below to map network drive and then fire up an app
in a sub dir of that drive. However when using the file open dialog
from...
|
by: test3 |
last post by:
Hello folks,
I'm using System.Diagnostics.Process to start a thirdparty program
(that works perfectly when started via command line). I'm using...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
| |