View Single Post
  #2  
Old 05-10-2013, 01:18 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Greetings rdrovdahl,

Yes, you can use variables with ReadString and WaitForString.

Here's a python example script that does something similar to what I think you're wanting to do. Lines 378-404 (with comments) demonstrate using Send, WaitForString, and ReadString.
Code:
            for strCommand in vCommandsList:
                # Get date and time for use in log file naming
                strLogFilename = GetSafeFilename(strCommand)
                if not os.path.isdir(g_strPath + "ScriptOutput/"):
                    os.makedirs(g_strPath + "ScriptOutput/")
                strLogFilePath = (g_strPath + "ScriptOutput/" + 
                    g_strHost + "--" + strLogFilename + ".txt")
                try:
                    objLogFile = open(strLogFilePath,"w")
                # SecureCRT on Mac uses Python 2.5, so use old syntax.
                # Python 2.7 syntax:
                # except Exception as strError:
                except Exception, strError:
                    MsgBox(
                        "Could not open log file with error: " + str(strError))
                    break
                    
                # We only continue if we are able to open the results file.
                # Send the command to the remote
                g_objNewTab.Screen.Send(strCommand + "\r")
                # Wait for the command to be echo'd back to us.
                g_objNewTab.Screen.WaitForString(strCommand + "\r\n")
                # As mentioned earlier in comments above, if you want to
                # suppress escape sequences from being captured, set the
                # Screen.IgnoreEscape property = True.
                g_objNewTab.Screen.IgnoreEscape = True
                strResult = g_objNewTab.Screen.ReadString(strPrompt, 5)

Have you tried assigning currentdevice + "#" to a new variable (and using that variable instead of trying to combine the variable and string inside the argument list, like the following line shows?
Code:
    strPrompt = currentdevice + "#"
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote