Community discussions

MikroTik App
 
IceDiamond
just joined
Topic Author
Posts: 9
Joined: Tue Mar 20, 2007 9:44 am
Contact:

Scripts won't run

Fri Mar 23, 2007 11:08 am

None of my scripts will execute, even the simple ones. When I click the Run Script button (or execute the command using the terminal) nothing happens. No error, no execution, nothing.

What is causing this?
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26378
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Fri Mar 23, 2007 11:16 am

what version of RouterOS are you running, and also please show us one of your simple scripts.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Fri Mar 23, 2007 11:20 am

Could you be so kind and post script that isn't working?
 
User avatar
RedHat
newbie
Posts: 42
Joined: Wed Mar 14, 2007 3:23 pm
Location: Earth Planet
Contact:

Sat Mar 24, 2007 10:10 am

maybe ur scripts rights as a command .. but there is no thing to do it !!

pleaes tell us what the script wirung for .. ans what is the script :?:
 
IceDiamond
just joined
Topic Author
Posts: 9
Joined: Tue Mar 20, 2007 9:44 am
Contact:

Scripts won't run: Examples

Mon Mar 26, 2007 11:03 am

DynamicIP Script
--------------------
:log info "Dynamic IP Update Via Mail: Begin"

:global dip-interface "I-Burst"

:global dip-ip [ /ip address get [/ip address find interface=$dip-interface] address ]

:if ([ :typeof $dip-lastip ] = nil ) do={ :global dip-lastip 0.0.0.0/0 }

:if ([ :typeof $dip-ip ] = nil ) do={

  :log info ("Dynamic IP Update Via Mail: No ip address present on " . $dip-interface . ", please check.")

} else={

  :if ($dip-ip != $dip-lastip) do={

    :log info "Dynamic IP Update Via Mail: Attempting to Send Updated IP ". $dip-ip
    /tool e-mail send to="ip@internetguy.co.za" body=$dip-ip subject=([/system identity get name] . " New IP Address " . $dip-ip)
    :log info "Dynamic IP Update Via Mail: Sending UPDATE!"
    :global dip-lastip $dip-ip

  } else={ 

    :log info "Dynamic IP Update Via Mail: No change" 

  }

}

:log info "Dynamic IP Update Via Mail: End"
----------------------------------------------------------------------------------
Script2
--------
I attempted to run the following one line command, again nothing happens when I execute a command or click the button, to run the script. There is also no log messages.
/tool e-mail send to="ip@internetguy.co.za" body=$dip-ip subject=([/system identity get name] . " New IP Address " . $dip-ip)
----------------------------------------------------------------------------------

Strangely enough, I wrote a new script this morning to add a user and it runs.
/ tool user-manager user 
add subscriber=Justin name="Test" password="test" first-name="Justin" \
    last-name="Minnaar" phone="011 849 5336" location="Howick Gardens #56" \
    email="Test@Region.co.za" download-limit=100000000 \
    upload-limit=100000000 comment="Test account with 100k up and 100k down" disabled=no 
---------------------------------------------------------------------------------

Any advice would be appreciated.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Mon Mar 26, 2007 10:08 pm

:log info "Dynamic IP Update Via Mail: Attempting to Send Updated IP ". $dip-ip 
the above line is incorrect. Put ( ) around the text so it evaluates the statement.

Sam
 
IceDiamond
just joined
Topic Author
Posts: 9
Joined: Tue Mar 20, 2007 9:44 am
Contact:

Pity that the router's compiler does not log a compiler erro

Tue Apr 03, 2007 8:25 am

Thank you for your help. I have resolved the problem by deleting the offending line. I could not get ( ) around the string . string to work correctly and figured I would probably have to create a local variable but it was not neccessary. Anyway, the script runs now successfully! Funny enough, other lines have ( ) for logging info and work fine.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Tue Apr 03, 2007 10:45 am

correct code would be:
:log info ( "Dynamic IP Update Via Mail: Attempting to Send Updated IP " . $dip-ip )
and it works.
 
ZioN
just joined
Posts: 22
Joined: Sun Jun 12, 2011 4:12 pm

Re: Scripts won't run

Fri Sep 09, 2011 12:31 pm

Has anyone yet made an attempt at writing a basic syntax compiler for MT Scripts?

Or is MT Scripts based on a scripting language that has a compiler. Even if it wont compile completely, but just check the syntax symbols?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Scripts won't run

Fri Sep 09, 2011 12:34 pm

Syntax "compiler" is already built in.
Write a script and if there are any syntax errors
/system script print will highlight them.
 
tjc
Member Candidate
Member Candidate
Posts: 276
Joined: Sun Jul 10, 2011 3:08 am

Re: Scripts won't run

Sat Sep 10, 2011 2:51 am

I think the request was for an external syntax checker with diagnostics. That would definitely be a very useful tool.
 
ZioN
just joined
Posts: 22
Joined: Sun Jun 12, 2011 4:12 pm

Re: Scripts won't run

Mon Sep 12, 2011 11:25 pm

That would definitely be a very useful tool.
Yip. That would be great! Some form of a tool to guide you in the right direction when debugging. I sat once for 3 hours staring at a uncompilable script just to find a simple math error.

Has there been attempts at producing such a tool?

Who is online

Users browsing this forum: m3das and 42 guests