Simple script to access html page and cut some part of code

hi

i want to ask if somevody can help me with simple script
this is what i want it to do

  1. mikrotik should load a web page
http://user:pass@192.168.1.1/wancfg.cmd?action=view

this will return a table in html with my external ip, so i need to cut that ip from other not interesting info and that ip write to variable for examlpe “actual_ip”. the html answer looks like this

<html><head>
<link rel=stylesheet href='stylemain.css' type='text/css'>
<link rel=stylesheet href='colors.css' type='text/css'>
<meta http-equiv='refresh' content='5'>
<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
<title></title>
</head>
<body>
<blockquote>
<form>
<b>WAN informacie</b><br><br>
<table border='1' cellpadding='4' cellspacing='0'>
   <tr align='center'>
   <td class='hd'>Port/VPI/VCI</td>

      <td class='hd'>VLAN Mux</td>
      <td class='hd'>Con. ID</td>
      <td class='hd'>Kategoria</td>
      <td class='hd'>Sluzba</td>
      <td class='hd'>Rozhranie</td>
      <td class='hd'>Protokol</td>

      <td class='hd'>Igmp</td>
      <td class='hd'>QoS</td>
      <td class='hd'>Rezim</td>
      <td class='hd'>Stav</td>
      <td class='hd'>IP adresa</td>
   </tr>

   <tr align='center'>
      <td>0/1/32</td>
      <td>Off</td>
      <td>1</td>
      <td>UBR</td>
      <td>pppoe_0_1_32_1</td>

      <td>ppp_0_1_32_1</td>
      <td>PPPoE</td>
      <td>Zakazat</td>
      <td>Zakazat</td>
      <td>Povolit</td>
      <td>Up</td>

      <td>1.1.1.1</td>
   </tr>
</table>
</form>
</blockquote>
</body>
</html>

in this my external ip is 1.1.1.1

  1. create 2nd variable for example “previous_ip” with any value
    now script will compare values of variables “actual_ip” and “previous_ip”
    if they are NOT same, mikrotik will load another page
http://freedns.afraid.org/dynamic/update.php?123567890

and write “actual_ip” to “previous_ip”. or if they are same it wont load second page and after five minutes will start from beginning. only hard part is how to cut that ip
thats all

While theoretically possible, the scripting language in ROS won’t make that very friendly. It only has very rudimentary text processing functionality.

Have you considered using on the of the gazillion DynDNS/NoIP/etc. scripts flying about on the forums and on the wiki? Looks like they provide the same functionality, and it’s all already built for you.

i tought it is not possible in ROS (in linux by simple “cut” command :laughing:)
as i am looking at the html answer i dont need to cut out external ip and i can write whole html page into variable because only changing part is that with IP. so i dont need to cut that ip. so thanks. lets scripting :laughing:
i didnt want to use another script because i dont understand all things in them and i like if the solution is simple and another scripts looks not simple at all :slight_smile:

if that is your server, why your (seems php page) cannot just return some value as whole content of the page?

there is more effective ways of doing this, than with a file,

For the DNS you get 2 functions that work really well, the one is the HTTP GET command to load one of those

:global myip
:set myip [/ip address get [/ip address find interface=<>] address];

then u can write that to the file and do as you wish, but since u made it a global u might as well just use it further on.

Hope i understood u correctly, and that you ware after the Tik’s adress