VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   General (https://forums.vandyke.com/forumdisplay.php?f=11)
-   -   Prompt how to use multiple values (https://forums.vandyke.com/showthread.php?t=14082)

baf28 02-16-2020 09:50 PM

Prompt how to use multiple values
 
Hello
I use Nokia equipment
When I create a new interface in services, my session freezes due to the fact that first the prompt is # and then $:

A:KM002038-CSA01# configure service vprn 411002
A:KM002038-CSA01>config>service>vprn# interface "to_KM8038_ENB_S1" create
A:KM002038-CSA01>config>service>vprn>if$


How can I specify multiple characters in a command line wait string?
I did # || & - it did not bring success.

bgagnon 02-17-2020 09:01 AM

1 Attachment(s)
Hi baf28,

You would use WaitForStrings() as opposed to WaitForString(). :)

https://forums.vandyke.com/attachmen...achmentid=1824

baf28 02-17-2020 09:24 PM

I did not understand you. I do not use scripts to insert the configuration, I press ctr+v.
How then what you advised can be my best?

I canít understand how to specify two values for # and $ in the session settings?

baf28 02-17-2020 10:36 PM

I realized that they would have come out of what I pasted from the clipboard through a script. I took and modified one of your scripts, it turned out like this:
Code:

    sWait = 0
    for strLine in vLines:
        # Send the next line to the remote
        crt.Screen.Send(strLine + "\r")
       
        bSuccess = False
        # If the current line isn't empty, wait for it to be echo'd back to us
        if not strLine == "":
            # Wait for the remote to echo the line back to SecureCRT; bail if
            # the remote fails to echo the line back to us within 3 seconds.
            bSuccess = crt.Screen.WaitForStrings(["#", "$"], int(sWait))
        else:

And all the same, I think that a simple paste operation from the clipboard should not be cumbersome and executed by a script.
The simpler the better.

bgagnon 02-18-2020 08:47 AM

Hi baf28,

Are you saying you have configured Prompt in the Send delay options grouping in the Terminal / Emulation / Advanced category of Session Options?

If so, you can't presently specify multiple prompts.

I have added this thread to a feature request in our product enhancement database for the ability to specify multiple prompts for the send delay prompt option. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14082 in the subject line or use this form from the support page of our website.

baf28 02-18-2020 08:12 PM

Quote:

Originally Posted by bgagnon (Post 53088)
Hi baf28,

Are you saying you have configured Prompt in the Send delay options grouping in the Terminal / Emulation / Advanced category of Session Options?

If so, you can't presently specify multiple prompts.

I have added this thread to a feature request in our product enhancement database for the ability to specify multiple prompts for the send delay prompt option. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14082 in the subject line or use this form from the support page of our website.

Thank you, I will wait for the developers to implement this.
In the meantime, I made a script that does this and stops when it detects an error. If itís not difficult for you, look at it and maybe you will find errors in it. I would be very glad if you could help me make the script better.

Code:

# $language = "python"
# $interface = "1.0"

# PasteWaitForStrings.py
#
# Description:
#  Скрипт вставляет данные из буфера обмена и ждет определенные совпадения прежде
#  чем вставит следующую строку
#  Если скрипт зависнет или остановистя, то можно продолжать вводить данные и отменить скрипт

import SecureCRT
import time

crt.Screen.Synchronous = True
crt.Screen.IgnoreEscape = True

def main():
    # If there isn't an active connection, there's no point in continuing
    # since we can't send data.
    if not crt.Session.Connected:
        crt.Dialog.MessageBox("Для отправки данных требуется активное соединение.")
        return
   
    # If there isn't anything in the clipboard, it doesn't make any
    # sense to continue with the script.
    if crt.Clipboard.Text.strip() == "":
        crt.Dialog.MessageBox("Текст не найден в буфере обмена.")
        return
   
   
    # Keep timing information so that we can display how long it took for the
    # data to be sent to the remote (each line sent only after the prior line
    # was echo'd back to SecureCRT, as a flow control mechanism).
    nStartTime = time.time()

    # Multiple lines in the clipboard are typically stored with a CRLF
    # separator, but this script example tries to accommodate other line endings
    # that might be supported by some editors. Break up lines into an array
    # (each line as an element within the array).
    if crt.Clipboard.Text.find("\r\n") > -1:
        vLines = crt.Clipboard.Text.split("\r\n")
    elif crt.Clipboard.Text.find("\n") > -1:
        vLines = crt.Clipboard.Text.split("\n")
    else:
        vLines = crt.Clipboard.Text.split("\r")

    AllLineNumber = len(vLines)
   
    nLineNumber = 1
    sWait = 0
    for strLine in vLines:
        # Send the next line to the remote
        crt.Screen.Send(strLine + "\r")
        bSuccess = crt.Screen.WaitForStrings(["#", "$", "Error","Command not allowed for this user","Command authorization failed"], int(sWait))
        #crt.Dialog.MessageBox(str(bSuccess))
        if (bSuccess == 3):
            crt.Dialog.MessageBox("Обнаружена ошибка \"Error\" ! \r\n\r\n"
                                  "%d строки из буфера обмена были отправлены." % (nLineNumber-1))
            return
        if (bSuccess == 4):
            crt.Dialog.MessageBox("Команда не разрешена для этого пользователя! \r\n\r\n"
                                  "%d строки из буфера обмена были отправлены." % (nLineNumber-1))
            return
        if (bSuccess == 5):
            crt.Dialog.MessageBox("Ошибка авторизации! \r\n\r\n"
                                  "%d строки из буфера обмена были отправлены." % (nLineNumber-1))
            return

        nLineNumber += 1
   
    # Calculate seconds elapsed
    nTimeElapsed = time.time() - nStartTime
   
    # Inform that the data has all been sent.
    crt.Dialog.MessageBox(
        "{:d} строки из {:d} были отправлены с буфера обмена. \r\n\r\n"
        "Время выполнения: {:.2f} секунд.".format(nLineNumber-1,AllLineNumber,nTimeElapsed))

main()



All times are GMT -6. The time now is 05:38 PM.