Community discussions

 
ibeeby
newbie
Topic Author
Posts: 45
Joined: Tue Dec 12, 2006 8:49 am
Location: Matlock, England
Contact:

Differences between scripting for MIPS and x86 routers?

Sat Jun 05, 2010 4:43 pm

Folks,

I have a script which works just fine on a MIPS based RouterBoard (RB411U) but does NOT work on my x86 router. Both routers are running 4.9.

I can get a simple script to run on the x86 but it appears to run twice.

:log info "Hello World"

results in:

Hello World
Hello World

Also, the script that I am trying to put on the x86 unit (OpenDNS updater) seems to fail on the simplest of file i/o commands:

:local result [/file get $matichost contents]

Are there differences between scripting on RouterBoard and x86 systems and, if so, are they documented anywhere?

Best Regards

Ian
 
changeip
Forum Guru
Forum Guru
Posts: 3803
Joined: Fri May 28, 2004 5:22 pm

Re: Differences between scripting for MIPS and x86 routers?

Sun Jun 06, 2010 11:32 pm

should be no difference. look for differences in the script input... maybe put quotes around parameters.
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Thu Jun 10, 2010 1:56 pm

:log info "Hello World"

results in:

Hello World
Hello World
Sounds like you've got 2 x info log rules

Check under system logging for duplicates (maybe when you imported a config?)
 
ibeeby
newbie
Topic Author
Posts: 45
Joined: Tue Dec 12, 2006 8:49 am
Location: Matlock, England
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Sat Jun 12, 2010 2:11 pm

omega-00 is correct - I added an 'info, !firewall' logging stream at one stage and left 'info' in place.

With regard to the suggestion from changeip, I have to say that I am struggling to work out how to quote the script when some parts of it are already quoted by necessity. An example for a scripting newbie would be greatly appreciated.

Thanks for the follow-ups though...

Ian
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Sat Jun 12, 2010 9:23 pm

Are you able to post a copy of the script here or is it sensitive?

Alternatively you're welcome to email me a copy of it and I'll be happy to give it a try for you myself to see if I can replicate any problems.
Contact details are in my profile and sig \/
brightwifi.com | mikrotik-routeros.com | MTCNA,MTCWE.MTCTCE | Give karma where due
 
ibeeby
newbie
Topic Author
Posts: 45
Joined: Tue Dec 12, 2006 8:49 am
Location: Matlock, England
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Sun Jun 13, 2010 4:39 pm

Actually its just a script to update OpenDNS via DNSoMatic - there is a published on on the forum which did not work and which I fixed (and posted the fixed version). That version is working happily on an RB411U under RouterOS 4.9 but the same version will not run on the x86 router which is also running under 4.9.

Here is the script:

# DNSoMatic Account Information
:global maticuser "<username>"
:global maticpass "<password>"
:global matichost "<hostid>"
# End of Account Information

:global previousIP

# Recover previous IP address from file
:local result [/file get $matichost contents]
:local resultLen [:len $result]
:local startLoc [:find $result "d " -1]
:set startLoc ($startLoc + 2)
:set previousIP [:pick $result $startLoc $resultLen]

# Print values for debug
:log info "DNSoMatic: Updating dynamic ip on DNS for $matichost"
# :log info "DNSoMatic: User: $maticuser ; Password: $maticpass"
:log info "DNSoMatic: Last ip address: $previousIP"

# Get the current ip address from the internet (in case of double-NAT)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# Parse the current ip results
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:global currentIP [:pick $result $startLoc $endLoc]
:log info "DNSoMatic: IP actual $currentIP"

# Touching the string passed to fetch command on "src-path" option
:local str "/nic/update?hostname=$matichost&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"

:if ($currentIP != $previousIP) do={
:log info "DNSoMatic: Update needed"
:set previousIP $currentIP
:log info "DNSoMatic: Sending update to $currentIP"
:log info [ :put [/tool fetch host=MT user=$maticuser password=$maticpass mode=http address="updates.dnsomatic.com" src-path=$str dst-path=$matichost]]
:log info "DNSoMatic: Host $matichost updated on DNSoMatic with IP $currentIP"
:delay 300s
} else={
:log info "DNSoMatic: Previous IP $previousIP and current IP $currentIP are equal: No update needed"
}

Obviously I have removed the username, password and host identifier - signup to OpenDNS is free and painless.

The changes I made over the published script were to put in place a check from a stored version of the last ip address as declaring that as a global variable did not have the effect that it might have done when the script was written and the previous ip address was always 0.0.0.0.

Any assistance appreciated...

Best Regards

Ian
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Sun Jun 13, 2010 8:39 pm

Ok, gonna give this a try shortly.

Possibly a dumb question, but you do have DNS servers set on the x86 router right? :-)
 
ibeeby
newbie
Topic Author
Posts: 45
Joined: Tue Dec 12, 2006 8:49 am
Location: Matlock, England
Contact:

Re: Differences between scripting for MIPS and x86 routers?

Mon Jun 14, 2010 6:57 pm

Yes - DNS servers are set to OpenDNS on both (indeed, all) routers in my network.

Ian

Who is online

Users browsing this forum: No registered users and 12 guests