Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2020, 09:50 PM
baf28 baf28 is offline
Registered User
 
Join Date: Feb 2020
Posts: 4
Question 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.
Reply With Quote
  #2  
Old 02-17-2020, 09:01 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi baf28,

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

Attached Images
File Type: png WFSs_FromHelpFile.png (144.8 KB, 1514 views)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 02-17-2020, 09:24 PM
baf28 baf28 is offline
Registered User
 
Join Date: Feb 2020
Posts: 4
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?
Reply With Quote
  #4  
Old 02-17-2020, 10:36 PM
baf28 baf28 is offline
Registered User
 
Join Date: Feb 2020
Posts: 4
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.
Reply With Quote
  #5  
Old 02-18-2020, 08:47 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #6  
Old 02-18-2020, 08:12 PM
baf28 baf28 is offline
Registered User
 
Join Date: Feb 2020
Posts: 4
Quote:
Originally Posted by bgagnon View Post
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()
Reply With Quote
Reply

Tags
prompt

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:38 AM.