Oh my lord. The bytes read from StdoutPipe is not line by line!
[line] inspect skinny
inspect esmtp
[line] inspect sqlnet
[line] inspect sunrpc
inspect tftp
[line] inspect sip
inspect xdmcp
[line] policy-map type inspect dns migrated_dns_map_2
parameters
[line] message-length maximum client auto
message-length maximum 512
no tcp-inspection
!
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
profile CiscoTAC-1
no active
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
destination address email callhome@cisco.com
destination transport-method http
subscribe-to-alert-group diagnostic
subscribe-to-alert-group environment
subscribe-to-alert-group inventory periodic monthly
subscribe-to-alert-group configuration periodic monthly
subscribe-to-alert-group telemetry periodic daily
profile License
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
[line] destination transport-method http
Cryptochecksum:f615c78cc7913affb2f486489897b63e
: end
9dadcd0b-75f4-4a71-8a95-6f08c18d761c(config)#
Last line which end with prompt matched the prompt pattern, so this line was ignored by the code pasted above.
9dadcd0b-75f4-4a71-8a95-6f08c18d761c(config)#
1 Like
If you need to read lines, use bufio.Scanner
.
How to disable echoing?
var (
modes = cssh.TerminalModes{
cssh.ECHO: 0, // disable echoing
cssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
cssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
}
)
if err := session.RequestPty("xterm", 0, 0, modes); err != nil {
return nil, err
}
Set TerminalModes is helpless. The output read from StdoutPipe contains what we written to StdinPipe
dfc
(Dave Cheney)
June 28, 2017, 7:24am
25
Stop requesting a Pty, that is what is causing the remote end to think you are human and doing unhelpful things like pagination and echo.
dfc
(Dave Cheney)
June 28, 2017, 7:26am
26
With that said, we’ve already established that the cisco remote side is not really a shell so maybe it doesn’t behave like we hope.
You might have to filter out your input when it is returned to you.
I know there are lots of these types of programs wirtten in python and Perl, I’d recommend reading their source to understand how they worked around the unfriendly cisco console
ipcjk
(Jörg Kost)
July 5, 2017, 9:33am
27
I wrote and use this (mlxsh) almost all time in managing my Brocade routers. May also work for your Cisco if login is comparable. Take a look at the function readTill:
switch b.Router.PromptMode {
case "sshEnabled":
if targetMode == "sshConfig" {
b.ConfigureTerminalMode()
} else {
if err := b.Router.Write(b.RTC, "exit\n"); err != nil {
return err
}
}
case "sshConfig":
if targetMode == "sshEnabled" {
if err := b.Router.Write(b.RTC, "end\n"); err != nil {
return err
}
} else {
if err := b.Router.Write(b.RTC, "end\n"); err != nil {
return err
}
if err := b.Router.Write(b.RTC, "exit\n"); err != nil {
return err
Jörg
1 Like
system
(system)
Closed
October 3, 2017, 9:38am
28
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.