Below is a snippet of my code. I am using the Paramiko library and am attempting to manipulate data returned by the shell.
- The
output
is the raw data, var1
turns it into a list that I would like to index to get specific data to handle in the for loop,var2
isvar1
as a string which will be used for assertion at a later time,var3
is where the problems occur.var3
should only hold the specified index values ofvar1
.
My main concern is that when attempting to print screengrab
, I am still getting all of the values from var1
even though the for loop should ONLY be parsing through var3
. This was working fine yesterday until I made a few changes with the print statement and I am unsure where I went wrong. Any help would be greatly appreciated!
remote = ssh.invoke_shell()
(*send commands here*)
output = remote.recv(4000)
var1 = output.splitlines()
found_vals = []
var2 = str(var1)
if test_title == 'BGP Test':
var3 = var1[14:27]
if test_title == 'NAT Test':
var3 = var1[26:30] + var1[39:44]
if test_title == 'VPN-IPSECSA Test':
var3 = var1[8:10] + var1[18:22]
if test_title == 'LDAP Test':
var3 = var1[13:]
if test_title == 'FQDN Test':
var3 = var1
var2 = FQDN_output
if test_title == 'SCP Test' or 'Admin Access Test'or 'NTP Access Test':
var3 = var1
for x in var3:
screengrab = x.decode('utf-8')
found_vals.append(screengrab)
print(screengrab)
*FQDN_output is a global variable that is initialized in another function