Results 1 to 7 of 7

Thread: Redirecting Standard Input Output For Telnet Window

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    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.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    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.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: Redirecting Standard Input Output For Telnet Window

    any updates?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width