View Single Post
  #1  
Old 05-10-2013, 12:15 PM
rdrovdahl rdrovdahl is offline
Registered User
 
Join Date: May 2013
Posts: 3
Anyway to use variables in ReadString or WaitForString?

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!

Last edited by miked; 05-10-2013 at 12:29 PM. Reason: Put code brackets around the Python code to keep the correct formatting
Reply With Quote