c# - SSH.NET getting entire output from a shellstream -


ive encountered quite strange phenomenon; when using client.runcommand() function, entire output switch, when using own implementation:

sshclient cl = new sshclient(ip, username, password);  cl.connect();  shell = cl.createshellstream("tail", 80, 24,800, 600, 1024);  streamwriter wr = new streamwriter(shell); streamreader rd = new streamreader(shell);  wr.autoflush = true;  wr.writeline("show int status");  string rep = shell.expect("switch_wan#", new timespan(0,0,3)); messagebox.show(rep, "output"); 

i partial output, , prompt saying --more-- how can entire output switch?

an example partial output:

show int status  port    name        status  vlan    duplex  speed   type fa0/1   team7       connected   97  a-full  a-100   10/100basetx fa0/2   team7       connected   97  a-full  a-100   10/100basetx fa0/3   team7       connected   97  a-full  a-100   10/100basetx fa0/4   team7       connected   97  a-full  a-100   10/100basetx fa0/5   team7       connected   97  a-full  a-100   10/100basetx fa0/6   team7       disabled    97  auto    auto    10/100basetx fa0/7   team7       connected   97  a-full  a-100   10/100basetx fa0/8   team7       connected   97  a-full  a-100   10/100basetx fa0/9   team11      connected   11  a-full  a-100   10/100basetx fa0/10  team11      connected   11  a-full  a-100   10/100basetx fa0/11  team4       connected   94  a-full  a-100   10/100basetx fa0/12  team4       connected   94  a-full  a-100   10/100basetx fa0/13  team4       connected   94  a-full  a-100   10/100basetx fa0/14  team4       connected   94  a-full  a-100   10/100basetx fa0/15  team4       disabled    94  auto    auto    10/100basetx fa0/16  team11      connected   11  a-full  a-100   10/100basetx fa0/17  team11      connected   11  a-full  a-100   10/100basetx fa0/18  team11      connected   11  a-full  a-100   10/100basetx fa0/19  team4       connected   94  a-full  a-100   10/100basetx fa0/20  team4       connected   94  a-full  a-100   10/100basetx fa0/21  team4       connected   94  a-full  a-100   10/100basetx fa0/22  team4       connected   94  a-full  a-100   10/100basetx --more-- switch_wan# 

while using client.runcommand() function entire 48 ports in output.

thanks in advanced, if not clear, please so.

ps. before suggests, no, cant use client.runcommand(), must use streams.

p.p.s if explain values go cl.createshellstream("trail", 80, 24,800, 600, 1024); very thankful dont understand values go into

this looks similar working on recently. while simon's answer give more data, won't if return more data shell size (e.g. if have big switch lot of ports).

there 2 ways tried solve this:

1) read latest line , check presence of --more--

problem based on software version of switch, format different. broke usage.

2) 2nd , better option me using snmp information.

if want information switch, i'll use snmp rather ssh. information easy obtain if have correct oids. you'll need snmp walk information. library used snmpsharp.net (http://www.snmpsharpnet.com/)

as values go createshellstream method, here method declaration docs: public shellstream createshellstream(string terminalname, uint columns, uint rows, uint width, uint height, int buffersize)


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -