Core-Layer
  • Home
  • Blog
  • LINKS
  • ABOUT
  • Contact

Blog

[Cisco] - Call URL with a Cisco router (WGET) using IP SLA or TCL script

26/1/2016

1 Comment

 
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
ip sla 10
http raw http://core-layer.com version 1.1
frequency 60
http-raw-request
  GET /script.html?param1=1 HTTP/1.1\r\n
  Connection: keep-alive\r\n
  Authorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n
  \r\n
   exit

​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:
source "tmpsys:lib/tcl/http.tcl"

set arg1 [lindex $argv 0]

http::geturl " http://core-layer.com/script.html?param1=$arg1" -headers "Connection keep-alive Authorization \"Basic YWRtaW46cGFzc3dvcmQ=\""

​Here are a couple comments on that script
  - Many TCL script examples will tell you to add the reference to http this way:
package require http
​
Yet, Cisco stores librairies in « tmpsys:lib/tcl/» hence the following command:
source "tmpsys:lib/tcl/http.tcl"

  - To add HTTP headers you have to add parameter -headers which is then followed by headers formatted this way:
Header1 Value1 Header2 Value2 Header3 Value3 ...

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 \" . 
1 Comment
writemyessays.net reviews link
6/8/2019 08:04:17

We have been using Cisco for our class for over a year now, and this is the first problem that we encountered. It is really inconvenient for it to happen at such a time. I am willing to pay you extra if you are able to fix this as soon as possible. I may sound rude here, but we really need to use it immediately. I cannot give my students a grade without it, so please, help me out here.

Reply



Leave a Reply.

    Archives

    July 2021
    July 2018
    March 2018
    October 2017
    May 2017
    April 2017
    March 2017
    October 2016
    February 2016
    January 2016

    Categories

    All
    API
    Chrome
    Cisco
    Code Qr
    Covid
    Dev
    Données Personnelles
    Fix
    IIS
    Issue
    Linux
    Microsoft
    Moto
    Network
    News
    Python
    Qr
    Qr Code
    Quebec
    Raspberry Pi
    Roadtrip
    Securité
    Security
    SQL
    Vulnerability
    Windows

    RSS Feed

Proudly powered by Weebly
  • Home
  • Blog
  • LINKS
  • ABOUT
  • Contact