Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

Network Automation and Compliance (NetMRI)

Reply

Different actions depending on switch prompt (perl, netmri easy)

Techie
Posts: 5
2116     0

Running these versions : 

NetMRI Version : 7.4.2.97106
API Version : 3.4
NetMRI_Easy : 0.6

Script languange : Perl

 

Im looking for a way to check the prompt a cisco device is returning after a sent command and take appropriate actions. Prompt does change depending of outcome of command, sometimes its "]" and sometimes its "#".

 

If prompt = "]" then send command "yes"
If prompt = "#" then send command "copy run start"

 

Is this possible? If, then how?

 

Br

Magnus

Re: Different actions depending on switch prompt (perl, netmri easy)

Superuser
Posts: 115
2117     0

Can you past the examples of what commands you are sending and what it returns and is it all the same OS type like IOS/NX-OS or a mixed bag that you are running it on?

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Re: Different actions depending on switch prompt (perl, netmri easy)

Superuser
Posts: 115
2117     0

Also here is an example in CCS not sure about PERL or Python but let me do some research

 

Output-Triggers:
        router context Enterasys       
 
 
Trigger: router context Enterasys
Trigger-Filter: $Vendor eq "Enterasys"
Trigger-Context: true
 
##
## Command to enter a new context - this could involve a change in the prompt structure
##
Trigger-Context-Enter: enable
 
##
## Regular expression that defines the prompt structure for this context
##
Trigger-Context-Prompt: .*#
 
##
## Command to leave the context - the regular expression prompt structure will be reverted to what it was before.
## NOTE: This is the last thing in the trigger that is processed (i.e. after all Output-Triggers have finished).
##
Trigger-Context-Exit: exit
 
##
## Run some commands within this context
##
Trigger-Commands:
        configure
        ip route $Network $SubnetMask $Router $Metric
        exit
         
##
## Process the output of the above commands
##
Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Re: Different actions depending on switch prompt (perl, netmri easy)

[ Edited ]
Techie
Posts: 5
2117     0

switch#install remove inactive

If there are files eligable for deletion it will ask this question :
Do you want to remove the above files? [y/n]

Otherwise it just ends back in the regular prompt :
switch#

if prompt "]" then "y"
else do nothing.

Br
Magnus
(edited incorrect spelling)

Re: Different actions depending on switch prompt (perl, netmri easy)

Superuser
Posts: 115
2117     0

You can use the following 

 

install remove inactive \ry

 

or is it 

install remove inactive y\r

Will do it for you

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com
Showing results for 
Search instead for 
Did you mean: 

Recommended for You