|
-
Jan 24th, 2006, 04:59 AM
#1
Thread Starter
Lively Member
Redirecting Standard Input Output For Telnet Window
Can someone tell me why this doesnt work with telnet?
Code:
Process p = new Process();
StreamWriter sw;
StreamReader sr;
StreamReader err;
ProcessStartInfo psI = new ProcessStartInfo(@"c:\windows\system32\telnet.exe");
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
p.StartInfo = psI;
p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err = p.StandardError;
sw.Close();
textBox1.Text = sr.ReadToEnd();
textBox1.Text += err.ReadToEnd();
It just opens a cmd prompt really quick and then closes?
Does anyone know how to redirect the I/O of a telnet window?
Last edited by 2MuchRiceMakesMeSick; Jan 24th, 2006 at 09:03 AM.
-
Jan 24th, 2006, 08:01 AM
#2
Re: Redirecting Standard Input Output For Telnet Window
You have not escaped your string path. Change it to either of the following...
"c:\\windows\\system32\\telnet.exe"
@"c:\windows\system32\telnet.exe"
I don't live here any more.
-
Jan 24th, 2006, 09:04 AM
#3
Thread Starter
Lively Member
Re: Redirecting Standard Input Output For Telnet Window
whoops... i used the @ symbol instead (i just forgot to update it on here).
The code compiles fine but it wont redirect the I/O of telnet.
-
Jan 24th, 2006, 02:53 PM
#4
Re: Redirecting Standard Input Output For Telnet Window
I tried something similar this afternoon and I couldn't get the windows to stay open for more than a fraction of a second.
I was just trying to use MSDOS's copy command to concatenate a load of files together. It worked fine but It wouldn't stay open after it had finished th copy operation it just stopped as if it was running from a bat file. Very annoying. Also I couldn't get any of the Process's events to register either.
I gues Proces isn't very well suited to commandline or console-based apps.
I'll look into it some more tomorrow.
I don't live here any more.
-
Jan 25th, 2006, 02:23 AM
#5
Re: Redirecting Standard Input Output For Telnet Window
With the standard console you use the /k switch when starting it to force the window to stay open after the tasks have finished. I'm not sure if this also applies to telnet.
-
Jan 25th, 2006, 03:34 AM
#6
Thread Starter
Lively Member
Re: Redirecting Standard Input Output For Telnet Window
i tried it with the /k and it did not help
C:\>telnet -h
telnet [-a][-e escape char][-f log file][-l user][-t term][host [port]]
-a Attempt automatic logon. Same as -l option except uses
the currently logged on user's name.
-e Escape character to enter telnet client prompt.
-f File name for client side logging
-l Specifies the user name to log in with on the remote system.
Requires that the remote system support the TELNET ENVIRON option.
-t Specifies terminal type.
Supported term types are vt100, vt52, ansi and vtnt only.
host Specifies the hostname or IP address of the remote computer
to connect to.
port Specifies a port number or service name.
thanks for helping guys
-
Jan 30th, 2006, 09:48 AM
#7
Thread Starter
Lively Member
Re: Redirecting Standard Input Output For Telnet Window
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|