I've set up a function that logs into Cisco devices supplied via text file and runs commands also supplied from a txt file.
I need to capture all the outputs from the commands being run to a log file and need to be very specific about the ReadString and WaitForString entries every time the function is being run.
I'm trying to use a variable in as follows.
Code:
def commands(currentdevice):
crt.Screen.Synchronous = True
filep = open(LOGFILE, "ab+")
for line in open(COMMANDFILE, "r"):
crt.Screen.Send(line + '\r')
data = crt.Screen.ReadString(currentdevice + "#")
filep.write(data + "\n")
crt.Screen.WaitForString(currentdevice + "#")
return()
So far, I've not been able to find a way to use a
variable in the ReadString or WaitForString commands. Is there a way to do this or maybe some other method that would accomplish the same thing?
Thanks!