If you need to call a URL from a Cisco router (example: call a Web Service which will send an email...) as you would do using a WGET on a UNIX or Windows computer, here are two ways of doing it:
1. Using an IP SLA
The section http-raw-request will allow you to add HTTP headers if needed: for example, « Authorization: » header will allow the router to authenticate to the web page. That header si followed by authentication type (here « Basic ») and the string encoded in Base64: « username:password ». Which gives YWRtaW46cGFzc3dvcmQ= for admin:password .
You can then start the SLA using ip sla schedule 10...
2. Using a TCL script
The same kind of request can be created using a TCL script (saved in router's flash memory for example) and then directly called for the CLI with tclsh flash:script.tcl arg1 arg2 arg3 ...
Here is an example of TCL script saved in flash:
Here are a couple comments on that script
- Many TCL script examples will tell you to add the reference to http this way:
Yet, Cisco stores librairies in « tmpsys:lib/tcl/» hence the following command:
- To add HTTP headers you have to add parameter -headers which is then followed by headers formatted this way:
So you should always have an even number of strings after parameter -headers . If a header requires a value with spaces in it you have to escape " using \" .