11-01-2010 05:07 PM
Hi
I'm trying to copy a fragment of the IOS config (class-map update) into running-config using EEM (2.3 on 12.4.15T7):
event manager environment ip1 10.224.129.109
event manager applet MACUpdate
event timer watchdog time 30 maxrun 5
action 1.0 info type routername
action 2.0 cli command "enable"
action 3.0 cli command "config t"
action 4.0 cli command "file prompt quiet"
action 5.0 cli command "end"
action 6.0 cli command "copy http://$ip1/cgi-bin/rtr-mac-check.cgi?rtr=$_info_routername running-config"
action 7.0 cli command "config t"
action 8.0 cli command "no file prompt quiet"
action 9.0 cli command "end"
Need to track that the router has actually copied the file, so using the cgi (the rtr-mac-check.cgi does work if run manually on the router)
The problem is that EEM does not escape the "?" in the URL:
*Mar 10 06:30:25.669: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : R1#
*Mar 10 06:30:25.669: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : IN : R1#copy http://10.224.129.109/cgi-bin/rtr-mac-check.cgi?rtr=R1 running-config
*Mar 10 06:30:25.681: cli_history_entry_add: free_hist_list size=0, hist_list size=7
*Mar 10 06:30:25.681: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : http://10.224.129.109/cgi-bin/rtr-mac-check.cgi A URL beginning with this
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : prefix
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT :
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : R1#
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : %Error opening http://10.224.129.109/cgi-bin/rtr-mac-check.cgirtr=R1 (No such file or directory)
*Mar 10 06:30:25.725: %HA_EM-6-LOG: MACUpdate : DEBUG(cli_lib) : : OUT : R1#
Is there a way to somehow escape it, so it does not get dropped by the EEM?
Thanks
11-02-2010 01:46 AM
Try replacing the '?' with \134077:
action 6.0 cli command "copy http://$ip1/cgi-bin/rtr-mac-check.cgi\134077rtr=$_info_routername running-config"
11-02-2010 07:17 AM
Thanks for the hint, tried it, the IOS parser eats the \134 leaving only 077, so the copy in the appet fails. I tried \026? and it worked (\026 is the ctrl-V), in the IOS config it looks like:
action 6.0 cli command "copy http://$ip1/cgi-bin/rtr-mac-check.cgi^V?rtr=$_info_routername running-config"
Also rebooted the router to confirm that the parser would not reject it
Regards
11-02-2010 08:17 AM
Good to hear. I tested \134077 with a configuration change since I didn't have a CGI URL handy. This works:
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "event manager environment question \134077"
Thanks for the update.
02-27-2018 11:37 AM
04-23-2025 11:17 PM
I ran in to issues with a question mark in an EEM script as well. I ended up escaping the question mark with \x16 (the hex for Control-V).
So http://www.company.com/test.php?serial=1111 would be http://www.company.com/test.php\x16?serial=1111
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide