The "common-functions" widget cannot be found.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
cancel
Showing results for 
Search instead for 
Did you mean: 

EEM CLI command that includes quotes

srauen
Frequent Visitor
Frequent Visitor

I am working on an EEM script, but I've come to a roadblock. My script needs to run multiple commands, and it can run them all except one. This is a command that needs quotes in the command itself.

Is there a way to get an EEM script to run a command that has literal quotes in the command? I've tried all sorts of things like \"word\", (\"word\").... single quotes. None have worked so far.

action 4.2 cli command "group-policy "policy name with spaces""

 

1 Reply 1

mattmyers
Frequent Visitor
Frequent Visitor

A variable is needed to store the double quote since the action cli command won't let you enter double quotes within double quotes.  Also a literal \ is needed when calling the variable so that the it doesn't think your variable name is qpolicy in your action cli command.  I believe the actual cli command that runs as a result of the script is (group-policy \policy name with spaces")without parentheses but Cisco appears to not care about the \.  Note that after entering this if you perform a show run you will see the command action 103 set q """  As a result, after a reboot this command the """ will not survive and you'll need to enter it again as action 103 set q "\"".

Here is how you do this...

event manager applet test1 authorization bypass

event none

action 101 cli command "enable"

action 102 cli command "config t"

action 103 set q "\""

action 104 cli command "group-policy $q\policy name with spaces$q"