View Single Post
Old 10-15-2014, 04:35 PM
rtb rtb is offline
VanDyke Technical Support
Join Date: Aug 2008
Posts: 4,306
Hi kgaudineer,

You are welcome. I am hoping that this discussion will benefit others that want to use this example and read this thread.

I can see that my explanation is not very good. Adding additional ElseIf statements to the If...Then...Else condition would allow one to handle other interactive commands. For example:
If Instr(strCommand, "copy") > 0 Then
    ' Take special action
    ' If the command was of the following format:
    '     copy startup-config tftp,
    ' vData = Split(strCommand, ",")
    ' Send the command text to the remote
    ' g_objNewTab.Screen.Send vData[0] & vbcr
    g_objNewTab.Screen.Send strCommand & vbcr

    ' Wait "Address or name of remote host []" step
    g_objNewTab.Screen.WaitForStrings "#", "?"
    ' Send the IP address
    ' g_objNewTab.Screen.Send vData[1] & vbcr
    g_objNewTab.Screen.Send "" & vbcr
    ' Wait for "Destination filename [Cisco-2960-confg]" step
    g_objNewTab.Screen.WaitForStrings "#", "?"
    ' Press Enter to execute the command
    g_objNewTab.Screen.Send vbcr

ElseIf Instr(strCommand, "<additional interactive command>") > 0 Then
    ' Take special action for additional interactive command
    ' Proceed normally with a portion of the code
    ' Send the command text to the remote
    g_objNewTab.Screen.Send strCommand & vbcr

    ' Wait for the command to be echo'd back to us.
    g_objNewTab.Screen.WaitForString strCommand
End If
Does this help to clarify what additional ElseIf blocks can be used to do?

If you found another prompt that you needed to handle when trying to use the copy command, then you would need to modify the first If block. I can help explain how to do that, but I would need example output including the new prompt.

Did you find a new prompt that you need to handle as a part of the copy command?

VanDyke Software
Technical Support
Reply With Quote