Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: SSH stream keeps repeating last line

$
0
0
I've set up some code to read a shell stream back from OpenVMS, and this has been working perfectly, that is until I respond to the VMS requests for information.

For example VMS will output: <ESC>[c]
This is VMS basically asking what sort of terminal I am, so I respond with: <ESC>[?1;2c
Which means im a VT100

Great its working so far, but then VMS prompts with: <ESC>[6n
This is asking which line im on, so I respond with: <ESC>[24;80R
Which means im on row 24 column 80.
This is where the problem occures, now it simply repeats the same line over and over in the stream reader:
12/03/2015 08:13 []: Last interactive login on Wednesday, 11-MAR-2015 16:31:21.44
12/03/2015 08:13 []: Last non-interactive login on Wednesday, 11-MAR-2015 09:44:28.67
12/03/2015 08:13 []: System Detective is monitoring activity on this system.
12/03/2015 08:13 []: [c7[255;255H[6n8[c\Z[0c
12/03/2015 08:13 []: %SET-W-NOTSET, error modifying FTA1885:
12/03/2015 08:13 []: -SET-I-UNKTERM, unknown terminal type
12/03/2015 08:13 []: testdir is COUNTERDEV
12/03/2015 08:13 []: Initialising TEST Environment to COUNTERDEV
12/03/2015 08:13 []: [(0qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
12/03/2015 08:13 []: qq(B
12/03/2015 08:13 []: [#3   Using Test Search rules COUNTERDEV   [0m
12/03/2015 08:13 []: [#4   Using Test Search rules COUNTERDEV   [0m
12/03/2015 08:13 []: [(0qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
12/03/2015 08:13 []: qq(B
12/03/2015 08:13 []: 
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
12/03/2015 08:13 []: Automation Test
So basically "Automation Test" is the home directory when you look in. So kinda like C:\ where you go into command prompt.

Anyway here's the code im using:
PasswordAuthenticationMethod authMethod = new PasswordAuthenticationMethod(username, password);
ConnectionInfo connectionInfo = new ConnectionInfo(session, username, authMethod);
client = new SshClient(connectionInfo);
client.Connect();
                
stream = client.CreateShellStream(@"vt100", 80, 24, 800, 600, 1024);
                
reader = new StreamReader(stream);
writer = new StreamWriter(stream);
                    
writer.AutoFlush = true;
                
line = line + reader.ReadToEnd();
output = line.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    
or (int i = startPoint; i < output.Length; i++)
{
    //Server is asking which terminal type we are
    if (output[i].Contains((char)27 + "[c")&termSet==false)
    {
        //we reply VT100
        writer.WriteLine((char)27 + "[?1;2c");
        termSet=true;
        break;
     }
                    
     if (value.Contains("[6n", StringComparison.CurrentCultureIgnoreCase))
    {
        //we reply
        writer.WriteLine((char)27 + "[24;80R");
        break;
    }
}   
                
//Its at this point which the reader will just continue to grow.

foreach(string line in output)
{
    Console.WriteLine(line);
}
Does anyone know why this might be?
If I omit using: writer.WriteLine((char)27 + "[24;80R"); then the terminal waits around 8 seconds then it will output "Automation Test" just the once and its the end of the stream.

Thanks

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>