logs get mixed when using `expect_string` inside `send_command()`
See original GitHub issueHi! I’m trying out the new version of netmiko 4.1.0. I’m upgrading a set of tools that I was using with netmiko 3.4.0. I’m using device type nokia_sros
with a range of timos versions (7.x, 9.x, 16.x, 21.x).
When using send_command() with show-like commands, I used to store the received outputs both in a json file and a plain text file.
These are a snippet of the commands I’m sending to the router:
# SCRIPT_NONO_START
/environment no more
/show router bgp summary
/show router interface
/show service sdp
/show service sdp detail
This is how I store the recevied output:
try:
for cmd in cmdList:
rx = conn2rtr.send_command(cmd, expect_string=r"#", cmd_verify=True, read_timeout=10)
outputTxt = outputTxt + '\n' + cmd + '\n' + rx
outputJson[cmd] = rx
outputReason = ""
runStatus = 1
except Exception as e:
outputTxt = ''
outputReason = str(e)
runStatus = -1
But here is a problem. If I enable the expect_string
inside the send_command(), then my ouput both in the json or the text file, gets scrambled. The output on the left corresponds to the case where exptect_string
is enabled; on the right, I’m not using it. You can see on the left how the sent commands are being repeated, like echoed.
This is a snippet of the json file. Look how the values for each key, are mixed.
I was using the expect_string before, to speed up things, but the output gets corrupted.
However, everything seems to be allright if I do not use the expect_string
.
Any hint?
thanks!
Lucas
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Yes, that was it … thank you …
Have you tried:
In other words, are you sure there is no whitespace between the
#
and the end-of-line?